[Date Prev][Date Next][Thread Prev][Thread Next]
[Search]
[Date Index]
[Thread Index]
Re: [FWP] alien method calls
John Porter writes:
> I didn't realize until today that method names are only looked up
> in the objects's inheritance tree if unqualified. If qualified
> (and it goes without saying that Fully Qualified is the only kind),
> the fully named sub is called, regardless of the class of the object.
> Somewhat unexpected -- though not unpleasant.
Almost true. If you say:
Foo::moo($obj)
then you're specifying exactly which subroutine (ahem, method)
should be called.
If you say:
$obj->Foo:moo()
then you're starting the method search in Foo::, looking for the
method moo(). Inheritance applies with the -> but not with the
mundane sub call.
If you're doing this to call an overridden method, you probably
want
$obj->SUPER::moo()
Nat
==== Want to unsubscribe from Fun With Perl? Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
==== unsubscribe