in reply to Re^3: sub calls and memory use
in thread sub calls and memory use

> the call stack still grows since the return address needs to be stored on the call stack.

I'm pretty sure that this is not needed because you can't return to the source of a goto.

If it's stored nevertheless than it's for vain.

But I really doubt this because the docs clearly say that even caller can't tell where the call happened.

IMHO goto &sub was never optimized to allow tail call optimizations, it's main purpose is the use in AUTOLOAD.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Replies are listed 'Best First'.
Re^5: sub calls and memory use
by dave_the_m (Monsignor) on Nov 16, 2019 at 15:30 UTC
    I'm pretty sure that this is not needed because you can't return to the source of a goto
    Indeed, goto &foo pops the current call frame and replaces it with a new frame, rather than just pushing an additional one as a normal sub call would do. The following consumes lots of CPU but uses constant memory:
    sub foo { goto &foo }; foo();

    Dave.