Re: tail call and bounded space requirement
Marc Nieper-WiÃkirchen 28 Oct 2022 21:02 UTC
Am Fr., 28. Okt. 2022 um 22:55 Uhr schrieb Shiro Kawai <xxxxxx@gmail.com>:
>
> I assume the same applies to the parameterization, that is, the following should run in a constant space. Correct?
>
> (define p (make-parameter 0))
> (let loop ()
> (parameterize ((p 1))
> (loop)))
Yes, this is the expectation (and a reason why parameterize possesses
a tail-context guarantee. The idea is that a parameter is
conceptually the same as an implicit argument. An a loop like
(let loop ((p 0))
(loop 1))
also runs in bounded space.
I should check whether the sample implementation is correct in this regard.