Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^4: sub calls and memory use

by LanX (Saint)
on Nov 16, 2019 at 14:55 UTC ( [id://11108787]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11108787]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2024-04-25 15:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found