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: Sun, 08 Jan 2023 05:40:59 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Michael Heerdegen wrote:

>> (defmacro pushlast (newelt place)
>>   (declare (debug (form gv-place)))
>>   (if (symbolp place)
>>       (list 'setq place
>>             (list 'append place (list 'cons newelt nil)) )
>>     (macroexp-let2 macroexp-copyable-p x newelt
>>       (gv-letplace (getter setter) place
>>         (funcall setter `(append ,getter (cons ,x nil))) ))))
>
> LGTM.  But you can skip the special treatment of the simple
> (symbolp place) case since your macro is not used
> while bootstrapping.

Let's get that money!

;;; -*- lexical-binding: t -*-
;;
;; this file:
;;   https://dataswamp.org/~incal/emacs-init/list.el

(defmacro pushlast (newelt place)
  (declare (debug (form gv-place)))
  (macroexp-let2 macroexp-copyable-p x newelt
    (gv-letplace (getter setter) place
      (funcall setter `(append ,getter (cons ,x nil))) )))

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




reply via email to

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