in reply to My AUTOLOAD doesn't work in newer Perls. How to fix?

goto &$name effectively removes the calling block from the call stack. With the eval block gone, how would you trap errors (it won't even return anything)? Pick one: have the eval block in the call stack (and then use &$f;), or don't try to trap errors.

Replies are listed 'Best First'.
Re^2: My AUTOLOAD doesn't work in newer Perls. How to fix?
by John M. Dlugosz (Monsignor) on May 17, 2011 at 09:46 UTC
    I see what you mean. I don't expect it to trap an error in the dispatched function. I worry about an error in the goto itself, not finding the target or "going" there.

    Can that happen? I guess if $f is indeed not still undef and is a code ref, that should be good enough?

    Thanks.

      If you can live with just using &$f instead of goto &$f, then use that. (Just realize that &$f returns, while goto &$f doesn't - at least not to the place it was called from).

      If $f is a code ref, you're good. Otherwise, $f is a symbol, and you can provide messages for !exists(&$f) and !defined(&$f).