[plt-scheme] two tool ideas
On Friday, February 14, 2003, at 11:53 AM, Gregory Cooper wrote:
>
>>
>> I'm not sure we're talking about the same thing when we say 'tail
>> position,' in particular because I don't see how either argument to a
>> cons could ever be in tail position.
>>
>
> It depends on the evaluation strategy. The runtime could first
> allocate
> an uninitialized cons cell, and evaluation of the arguments could then
> "return" into the fields of the cell. In this case, the second
> argument
> of the cons will sometimes behave as if in tail position. Wadler's
> "listless" work deals with optimizations for such programs, which are
> said
> to be "tail-recursive modulo cons".
I wouldn't call this tail recursive. Tail-recursive modulo cons,
maybe, but not tail-recursive. In particular, I think that this
program is going to grow without bound, no matter how you implements
cons--even omitting the memory taken by the cons cells:
(define (loop x)
(cons 3 (loop x)))
(loop 5)
Perhaps you could allocate extra space in every cons cell for the
activation record? Yikes.
john