[Top][All Lists]

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

Re: named-let

From: Andrea Corallo
Subject: Re: named-let
Date: Mon, 11 Jan 2021 23:28:08 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>> With the advent of the native-compiler, "all implementations" is even
>>> harder to reach, since it means, interpreter, byte-code, and native code.
>> Well as I mentioned the native compiler is already capable of that if
>> asked, but in general whichever optimization is done by the
>> byte-compiler is picked by the native compiler cause currently the
>> compilation input is LAP.  So I'm not really sure this is adding much
>> complexity from this POV.
> All the patches I've seen so far do it in the bytecode interpreter,
> without changing the bytecode itself.

Ah okay, as not said, indeed it should use a goto in bytecode.

> Note that it also depends on what we mean by TCO.
> To me, the "real TCO" is like what Scheme does (so it's not limited to
> recursive functions).  I don't know how easy it is to implement for
> native-comp.  Maybe GCC magically does it for us?

Nope, AFAIU it does it, but not for us (ATM) :)

> [ 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 ()

Indeed this does not apply for `named-let' where the scope is lexical
and so you could do the magic :)

>> As a side note I'd be surprised if interpreters in CL implementation are
>> supporting TRE, I guess the interpreter is typically used only for debug
>> or bootstrap therefore should be not very important.  Am I wrong?
> I wouldn't know.  But at least for ELisp , it was perceived that
> the plain interpreter is important enough that if it doesn't support TCO
> then we can't write code which relies on TCO, in which case implementing
> TCO in the bytecode interpreter is not very useful.
> [ That's part of the reason why I implemented this limited TCO as
>   a macro: it works the same for bytecode as for any other mode of
>   execution so it can really be considered part of the guaranteed
>   semantics rather than a mere optimization.  ]

I see.



reply via email to

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