in reply to Re: oop - obvious AUTOLOAD question
in thread oop - obvious AUTOLOAD question

The goto after AUTOLOAD is a shortcut, so that you don't have to make a new stack frame, etc, when you pass control to the new method.

update:oops. This was a response to node 200692 but something went wrong with the links. thanks footpad

Edited: ~Wed Sep 25 22:30:46 2002 (GMT) by footpad: Reparented, per Consideration.

  • Comment on Re: Re: oop - obvious AUTOLOAD question

Replies are listed 'Best First'.
Re: Re: oop - obvious AUTOLOAD question
by rir (Vicar) on Sep 25, 2002 at 20:57 UTC
    In my tests a goto &rout is slower than a plain rout.

    I don't usually care much about micro-optimizations, but
    given that AUTOLOAD is a slug, it seems a bad time to
    imply that an arcane construct is faster than a normal call.

      it seems a bad time to imply that an arcane construct is faster than a normal call.

      I don't think anyone attempted to imply anything about the efficiency of using goto. As you almost pointed out, if you are using AUTOLOAD in the first place, efficiency probably isn't your primary consideration. The real point to it is correctness. Using goto hides the fact that the code is AUTOLOAD'd. The AUTOLOAD'd code can then do things like call caller() without worrying or wondering whether it was called directly.

      -sauoq
      "My two cents aren't worth a dime.";
      
        I think fglock's shortcut ... stack frame comment seems difficult to read
        any other way. If I'm missing something here please let me know because I
        think you're way off-base.

        I find your other point difficult to swallow. It sounds like conventional
        wisdom but is not.

        Correctness, is good. But hiding where a routine was called from is not correct.

        Why lie about a code trace?!

        Correct would be to do a two-step dance: have your routine
        use caller and have AUTOLOAD use it too.