[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: named-let

From: Stefan Monnier
Subject: Re: named-let
Date: Mon, 11 Jan 2021 18:57:36 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>> [ TCO has also undesirable interactions with debugging/tracing, but
>>   I think that would be a secondary concern which should be
>>   manageable somehow.  ]
> It's also a change in semantic as one must assume that `bar' is not
> redefining `foo'.
> (defun foo ()
>   (bar)
>   (foo))

I think there's a bit of confusion: you can have TCO without having to
pay any attention to whether `bar` changes `foo`.  True TCO will also
avoid eating up stack space when you have code like

    (defun foo (x)
      (baz (1+ x)))


    (defun foo (x)
      (funcall (if (something) #'bar #'foo) (1+ x)))


    (defun foo (x)
      (let ((k (lambda (y) (foo (1+ x)))))
        (k 5)))

or ... and that doesn't depend on analyzing the code at all.

IOW, it shouldn't matter whether it's a recursive call or whether it's
a call to "self": all calls in tail position would conceptually pop
their stack frame before jumping to the destination function.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]