[Top][All Lists]

[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: Wed, 22 May 2019 03:00:11 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:

> Yeah, maybe a "place alias" is a generalization of symbol-macro.
> Actually, no: [...]

I see Graham using symbol macros to abbreviate normal code in "On Lisp".
That's enough evidence for me not to touch symbol-macrolet.

> [...] symbol-macro can also expand to other macro-calls which are
> supposed to be re-expanded at each use-site, AFAIK, so it can
> macro-expand to something different every time the "variable" is
> referenced, which is not the case of places, I think.

With our current implementation of local macros, only the expansion
(compile) time matters, so this not so simple to do:

(let ((l '(0 1 2 3))
      (i '(0 1 2 3))
      (flag nil))
  (cl-macrolet ((yyy () (if flag '(nth 2 l) '(nth 3 i))))
    (cl-symbol-macrolet ((xxx (yyy)))
      (setf xxx 0)
      (list l i))))
|- void-variable: flag

(defvar flag t)

(defmacro zzz () (if flag '(nth 2 l) '(nth 3 i)))

(let ((l '(0 1 2 3))
      (i '(0 1 2 3))
      (flag nil))
  (cl-symbol-macrolet ((xxx (zzz)))
    (setf xxx 0)
    (list l i)))

==> ((0 1 2 3)
     (0 1 2 0)) ;; FLAG has been checked at expansion time

I could move the check of FLAG into the expansion, but that's not what
you meant, and since you made `if` forms place expressions, it would not
even be a counterexample any more.


reply via email to

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