Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^6: Who's a thief? (No memory growth with magic goto)

by dragonchild (Archbishop)
on Jan 14, 2005 at 19:59 UTC ( #422369=note: print w/replies, xml ) Need Help??


in reply to Re^5: Who's a thief? (No memory growth with magic goto)
in thread Who's a thief? -- the follow up

I've never seen doing a goto to a reference of a named subroutine. Does this really get around the non-tail-recursive nature of goto &deep;?

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Replies are listed 'Best First'.
Re^7: Who's a thief? (No memory growth with magic goto)
by BrowserUk (Pope) on Jan 14, 2005 at 20:54 UTC

    From perlsyn:

    The goto-&NAME form is highly magical, and substitutes a call to the named subroutine for the currently running subroutine

    Limbic~Region's post referenced a post by TimToady which will give the real skinny of how it works, but it does avoid the stack growth at the penalty of requiring the programmer to arrange for the algorithm to be tail-recursive.

    You can use closures to provide yourself with one or more "stacks" if that is required. By controlling what gets stacked and when, even some non-tail recursive algorithms can benefit from reduced memory consumption and greater speed. It is especially useful for mutually recursive algorithms that need to share intermediate results.

    That takes some effort, but if you have an inherently recursive algorithm that lends itself to that process, and a need for speed, then it can be worth it.


    Examine what is said, not who speaks.
    Silence betokens consent.
    Love the truth but pardon error.
      I've seen goto ⊂ ... I've never seen goto \⊂, which is what you did. Is there a difference?

      Being right, does not endow the right to be rude; politeness costs nothing.
      Being unknowing, is not the same as being stupid.
      Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
      Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

        Sorry, I didn't even notice that I typed \& through force of habit. And no, it appears to make no difference whatsoever.

        Perl DWIMs again :)


        Examine what is said, not who speaks.
        Silence betokens consent.
        Love the truth but pardon error.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2019-11-20 17:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (100 votes). Check out past polls.

    Notices?