[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

Re: On Pseudohashes



Tom Christiansen <tchrist@chthon.perl.com> writes:
>>It's always been advisable for classes to pre-declare all their methods
>>if using AUTOLOAD.
>
>Tim, some time ago something came up about autoloading method calls
>that bothered me in an MI scenario.  Seems to me you respondedi
>similarly then.  I'm pretty sure it was the following inheritance
>scenario:
>
>                A
>                 \
>                  B   C         @B::ISA = ('A');
>                   \ /
>                    D           @D::ISA = ('B', 'C');
>
>Suppose that each of those classes were using autoloading to generate
>its attribute accessors.  If D->m() is called, and that method m()
>is really supposed to be handled iby C, there's no way for B's
>autoload to "super" it over to C.  Instead, B::SUPER just gets to
>ascend to A--which doesn't help.  You can never renege on an AUTOLOAD
>so that Perl's method lookup would treat that hit as a miss and
>then go on to inspect sibling branches of the tree.
>
>Does pre-declaring methods to be handled via AUTOLOAD entirely clear
>this matter up?  

Yes. There will be a stub in C so that will trigger "call" C::method
which will then AUTOLOAD.

>If there some obvious advantage to using AUTOLOAD
>over, say, iterated registration of closures in the package symbol
>table?  

Only the reduction in memory use by not having subs for methods
you are not using. My impression is that closure scheme is fairly 
efficient though - one op tree for the sub with the "variables" hung 
off the side.

>In my libertine youth, I would frequently advocate AUTOLOAD
>to cover generic accessor methods, but in later years I've grown
>to mistrust in the extreme that particular strategy for realistically
>complex class hierarchies.
>
>--tom
-- 
Nick Ing-Simmons <nik@tiuk.ti.com>
Via, but not speaking for: Texas Instruments Ltd.


References to:
Tom Christiansen <tchrist@chthon.perl.com>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]