emacs-devel
[Top][All Lists]
Advanced

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

Re: Why is FUNC in cl-callf not allowed to be an expression?


From: Michael Heerdegen
Subject: Re: Why is FUNC in cl-callf not allowed to be an expression?
Date: Thu, 16 May 2019 16:37:26 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:

> Hmm... that's indeed what I see, but I haven't yet understood why that
> is (or rather, why that doesn't happen to your gv-ad-hoc-place).  I
> guess that qualifies as a bug in gv-synthetic-place (not that it
> matters too much: I can't find a single use of it).

Well, let's see:

;; works:
(let ((l '(0)))
  (cl-symbol-macrolet ((p (gv-synthetic-place (car l) (lambda (v) `(setcar l 
,v)))))
    (setf p 1))
  l) ;; ==> (1)

;; dosn't work:
(let ((l '((0))))
  (let ((cl (car l)))
    (cl-symbol-macrolet ((p (gv-synthetic-place cl (lambda (v) `(setcar cl 
,v)))))
      (setf p 1)))
  l) ;; ==> ((0))

;; but this works
(let ((l '((0))))
  (let ((cl (car l)))
    (setf (gv-synthetic-place cl (lambda (v) `(setcar cl ,v))) 1))
  l) ;; ((1))

The problem in the second case is that `cl-symbol-macrolet' is too
eager: it also macroexpands the symbol expansion `p' inside the `setf',
i.e. it expands the `gv-synthetic-place' macro call, to just `cl', so
you get (setf cl 1).

That just doesn't happen to my version since it's a function instead of
a macro (and the compiler macro seems to be applied later).

Any suggestions?


Michael.



reply via email to

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