From: "Tagore Smith" <[EMAIL PROTECTED]> > Thanks :). That's great. I don't use goto much, except for a couple of > very specific situations, so I hadn't read the docs for goto. It > seems I missed a very interesting beast in goto &NAME. In fact , I > sent a friend of mine some code recently that would have been improved > in one place by its use. > > But I still have a question :). As I understand it when tail-call > optimization is done automatically there are two advantages. One is > that the stack doesn't grow out of control, so that you don't have to > worry about blowing it up if you recurse very deeply. The other is > that the overhead of successive calls is eliminated. In theory (but, I > think, often not in practice) the optimized routine should be as > efficient as the equivalent iterative routine. Using goto &name has > the first advantage, but does it have the second? That is, does goto > &NAME have the same overhead as a normal call?
No it does not. On the other hand most usualy it will still be slower that rewriting the code to iterative. That is ... if you assign to @_ before the goto &NAME and later extract the values from it to lexical variables. Besides ... Benchmark.pm is your friend. Try it out :-) > Does anyone write this kind of recursive function regularly? I mean, > is it idiomatic in the more rarefied Perl circles? Or is it better > (from a style point of view) to use iterative constructs even in > places where recursion is more natural, but tail-call optimization > would be required? I think next to noone uses this kind of recursive functions. I think I am crazy and I do have a functional language background, but still I would not use it. I know about it, but it would not come to my mind when coding normaly. In any case ... if you ever use this, please comment it heavily. Jenda =========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ========== There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]