[plt-scheme] tail position

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Fri Nov 21 08:23:41 EST 2003

Both calls are non-tail calls. In both cases you must disable ec
before you return. Observing memory isn't reliable in the presence
of gc, "precise" or "hostile". -- Matthias


On Friday, November 21, 2003, at 05:38 AM, Daniel Silva wrote:

>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> If this (f x) is in tail position:
>
>  (define (f x)
>    (call-with-escape-continuation
>       (lambda (ec)
>          (let ([s (void)])
>            (set! s (make-string 1000000))
>            (collect-garbage)
>            (display (current-memory-use))
>            (newline)
>            (f x)))))
>
> then why isn't this one?
>
>  (define (f x)
>    (let ([s (void)])
>      (call-with-escape-continuation
>        (lambda (ec)
>          (set! s (make-string 1000000))
>          (collect-garbage)
>          (display (current-memory-use))
>          (newline)
>          (f x)))))
>
> The second example shows a 1MB increase at every iteration, while the
> first one does not.
>
> Daniel



Posted on the users mailing list.