in reply to Re: Re: Re: Re: oop - obvious AUTOLOAD question
in thread oop - obvious AUTOLOAD question
Correctness, is good. But hiding where a routine was called from is not correct.
It may be, for certain values of "correct" :-)
If I autoload methods that log (as an example of use of) caller() information, I would not like seeing in my logs:
My::Lazy::method called from My::Lazy::AUTOLOAD [... later ...] My::Lazy::method called from Some::Other::method [... and ...] My::Lazy::method called from Yet::Another::method
While correct, in a sense of the word, the information given in the first of these lines is not useful. And I don't want to make AUTOLOAD smart enough to know what to do with caller information in every case. That would defeat the purpose of AUTOLOAD. And so, I use goto instead.
With goto, I get the caller information I would get if I were not using AUTOLOAD.
If your correctness criterion is that the sub should behave as if it was already in existence, and not autoloaded, then goto provides that correctness.
The Sidhekin
print "Just another Perl ${\(trickster and hacker)},"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
AUTOLOAD and call tracing
by rir (Vicar) on Sep 26, 2002 at 15:15 UTC | |
by Sidhekin (Priest) on Sep 26, 2002 at 15:28 UTC | |
by rir (Vicar) on Sep 26, 2002 at 17:03 UTC | |
by Sidhekin (Priest) on Sep 27, 2002 at 09:21 UTC |