From: gabriele renzi Date: 2005-12-17T23:27:46+09:00 Subject: Re: Ruby tail recursion Neil Stevens ha scritto: > Jakub Hegenbart wrote: > >>Tail calls are essentialy safe GOTOs with argument passing, there is a >>potential for performance gain. ;-) But in Ruby, its benefits wouldn't >>be that noticeable, I guess...I kind of don't think that the programming >>style that Ruby encourages is a good candidate for tail call >>optimization. :-D > > > Good point. Tail-call recursion is just a form of recursion that's easy > to turn into iteration, but (at least to me) one of ruby's strengths is > its iterators, so one might as well just write code in iterative form > instead of tail-call recursive form! > well, but maybe it could be nice to write iterators in a recursive way, i.e class Parser def each_token &blk tok=shift_token! blk.call(tok) each_token(&blk) end end