This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Tail recursion and hobbit (was: finite state machines in guile)



> Exactly. For instance, the following is not tail call optimized:
> 
> (define (fact n)
>   (if (<= n 1)
>       1
>       (* n fact (- n 1))))
> 
> even if equivalent to the original factorial. But guile's interpreter may
> also fail to optimize this (I have no way to verify this, any hint ?).

Guile's interpreter does do this correctly, by making the eval
function handle tail-position function application directly.  So this
function shouldn't allocate any new frames.