help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Easy to add with push but not to the end of a list


From: Emanuel Berg
Subject: Re: Easy to add with push but not to the end of a list
Date: Tue, 06 Dec 2022 02:43:10 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Michael Heerdegen wrote:

> Use `macroexpand' and/or `macroexpand-1' to check the
> expansion of macro calls. The rest is just...normal Elisp.
> You know how to write Elisp, so write it so that the
> expansion you want is generated. It's code returning code.
> So what's the code you want to produce?

I don't know, because this can't be done with Elisp, not any
Elisp I know anyway, since the variable name will then be
evaluated ...

Here is the `push' macro - TBH, I don't know what most of that
means ...

(defmacro push (newelt place)
  "Add NEWELT to the list stored in the generalized variable PLACE.
This is morally equivalent to (setf PLACE (cons NEWELT PLACE)),
except that PLACE is evaluated only once (after NEWELT)."
  (declare (debug (form gv-place)))
  (if (symbolp place)
      ;; Important special case, to avoid triggering GV too early in
      ;; the bootstrap.
      (list 'setq place
            (list 'cons newelt place))
    (require 'macroexp)
    (macroexp-let2 macroexp-copyable-p x newelt
      (gv-letplace (getter setter) place
        (funcall setter `(cons ,x ,getter))))))

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

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