develooper Front page | perl.perl6.language | Postings from July 2006

Another quick one: .as<ancestor>

Thread Next
From:
Aaron Sherman
Date:
July 12, 2006 09:52
Subject:
Another quick one: .as<ancestor>
Message ID:
1152723117.28796.426.camel@pps
I would assume that all classes automatically define:

 multi submethod *infix:<as> ($self: $?CLASS) { $self }

so that derived classes can automatically:

 $obj.as<ancestor>

Without actually changing their implementation details (only the type
that Perl currently thinks it's dealing with polymorphically).

In fact, I would expect that this bit of behind-the-curtain magic is how
the MCP arranges for polymorphism when you:

 sub foo(Object $x) {...}
 my A $y;
 foo($y);

Is all of that fair?

-- 
Aaron Sherman <ajs@ajs.com>
Senior Systems Engineer and Toolsmith
"We had some good machines, but they don't work no more." -Shriekback



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About