[plt-scheme] begin0 and tail recursion

From: Robby Findler (robby at cs.uchicago.edu)
Date: Sun Jul 20 09:47:04 EDT 2003

begin0 doesn't tail call any thing. 

(begin0 E1 E2) = (let ([x E1]) (begin E2 x))

Robby

At Sun, 20 Jul 2003 15:36:34 +0200 (MEST), Stefan Ottosson wrote:
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> 
> Hi,
> 
> I'm probably being naive, but shouldn't the following code be tail
> recursive? It seems it isnt, unless you remove 'pop from the second
> last line.
> 
> (define (faki n)
>   (define (iter n res)
>     (if (= n 0)
>         (continuation-mark-set->list
>                      (current-continuation-marks) 'key)
>         (with-continuation-mark 'key (gensym 'env)
>                                 (begin0 (iter (- n 1) (* n res)) 'pop))))
>   (iter n 1))
> 
> (faki 3) returns (env32208 env32207 env32206) as written above. If I
> erase 'pop then (faki 3) returns just (env32211).
> 



Posted on the users mailing list.