Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: Re: Re: Re: Pure Perl tail call optimization

by tilly (Archbishop)
on Mar 11, 2004 at 03:14 UTC ( [id://335695]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Re: Pure Perl tail call optimization
in thread Pure Perl tail call optimization

The deeper issue that always comes up is that tail-recursion would make caller give very different results. Which is a lot of fun when you are trying to debug a complex call. (Carp depends on caller for its output.)

Another subtle change is different destruction mechanics. In order to do tail-recursion, you have to clean-up your current variables, etc. With reliable destruction mechanics, this may cause interesting surprises. For instance consider the technique at •Re: sub and anonymous sub. Or consider ReleaseAction. Their behaviour changes. It already changes with goto, but at least there is an easily explained cause for the change. If it is done behind the programmer's back, how do you address the confusion?

I should also note that writing recursive routines that automatically perform iteratively makes more sense in Scheme where function calls are very cheap. When they are relatively expensive (as they are in Perl), the coolness isn't quite as compelling...

  • Comment on Re: Re: Re: Re: Re: Pure Perl tail call optimization

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-18 15:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found