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)},"


In reply to Re: Re: Re: Re: Re: oop - obvious AUTOLOAD question by Sidhekin
in thread oop - obvious AUTOLOAD question by princepawn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.