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: Mon, 27 May 2019 02:20:27 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:

> Indeed, they're closely related but symbol-macrolet does not "evaluates"
> anything at the "binding" site.  Also it can also be used for purposes
> different from "places", e.g. to keep a log of all the accessed to
> a "variable" (tho, we could just as well create a (journaled PLACE)
> pseudo place which would record accesses in the very same way).

I also come to the conclusion that symbol-macrolet and place binding are
two different things.

E.g. in

(macroexpand-all
 '(gv-place-bind ((p (car (cdr x))))
    (progn (cl-incf p) p)))

==>
 (let*
    ((#1=#:v
      (cdr x)))
  (progn
    (setcar #1#
            (1+ #2=(car #1#)))
    #2#))

we want that the (cdr x) "calculation" is factored out because it is
always the same (an "inner place" reference so to say).

OTOH, `symbol-macrolet' might be used for arbitrary calculations.  It
would be surprising (wrong) if in

(symbol-macrolet ((r (list (random))))
  (list r r))

the `random' function would be called only once.

One can't reliably guess from the bound expression which case the coder
wants, so I'll leave s-macrolet as is.

Michael.



reply via email to

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