GNU bug report logs -
#26073
How should cl-symbol-macrolet interact with rebindings?
Previous Next
Reported by: Paul Pogonyshev <pogonyshev <at> gmail.com>
Date: Sun, 12 Mar 2017 13:26:01 UTC
Severity: normal
Tags: fixed
Fixed in version 27.1
Done: Noam Postavsky <npostavs <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
I frankly don't know how it should behave and whether fixing it for
generators would break 'with-slots'. What I can see, however, is that
generator functions with nested lambdas do not work properly. And you
cannot realisctically say "don't use those", because lambdas can be just
introduced by macros without you even thinking about it. And then the
function unexpectedly produces wrong results without any hint of what might
be wrong.
Paul
On 26 September 2017 at 16:38, Stefan Monnier <monnier <at> iro.umontreal.ca>
wrote:
> retitle 26073 How should cl-symbol-macrolet interact with rebindings?
> thanks
>
> The problem here is indeed different from the one in bug#26068.
> bug#26068 was clearly triggering a (known) bug in cl-symbol-macrolet.
>
> Here it's triggering a (known) misfeature. The source code has the
> following comments about it:
>
> ;; CL's symbol-macrolet treats re-bindings as candidates for
> ;; expansion (turning the let into a letf if needed),
> contrary to
> ;; Common-Lisp where such re-bindings hide the symbol-macro.
> and
> ;; FIXME: The behavior of CL made sense in a dynamically scoped
> ;; language, but for lexical scoping, Common-Lisp's behavior
> might
> ;; make more sense (and indeed, CL behaves like Common-Lisp
> w.r.t
> ;; lexical-let), so maybe we should adjust the behavior based
> on
> ;; the use of lexical-binding.
>
> more concretely cl-symbol-macrolet implements the following semantics:
>
> (cl-symbol-macrolet ((x <e>))
> ... (let ((x <foo>)) ..x..))
> =>
> ... (cl-letf ((<e> <foo>)) ..<e>..)
>
> whereas Common-Lisp's symbol-macrolet wants the following semantics
> instead:
>
> => ... (let ((x <foo>)) ..x..)
>
> As mentioned in the comment, it probably makes sense to change
> cl-symbol-macrolet in lexical-binding code to follow Common-Lisp's
> semantics (tho we'd want to give access to the old semantics if the user
> explicitly uses cl-letf).
>
> Not sure what might break if we do that: the main user of
> cl-symbol-macrolet outside of generator.el AFAIK is the with-slots of
> eieio, so the question is whether some users of with-slots expect
> a subsequent `let` binding to temporarily change the slot's value.
> I just checked and it seems that no code in Emacs itself relies on this
> behavior, so maybe it's "safe" to change it.
>
>
> Stefan
>
[Message part 2 (text/html, inline)]
This bug report was last modified 7 years and 100 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.