emacs-devel
[Top][All Lists]
Advanced

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

Re: Double unquote/unquote-splicing


From: Stefan Monnier
Subject: Re: Double unquote/unquote-splicing
Date: Mon, 04 Nov 2013 12:27:00 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

> (defmacro once-only (names &rest body)
>   (let ((gensyms (loop for n in names collect (gensym))))
>     `(let (,@(loop for g in gensyms collect `(,g (gensym))))
>       `(let (,,@(loop for g in gensyms for n in names collect ``(,,g ,,n)))
>         ,(let (,@(loop for n in names for g in gensyms collect `(,n ,g)))
>            ,@body)))))

There are two reasons why I'm resisting it:
1- the above code looks clean, but I can't understand it at all.
   Your alternative code is less clean and not easy to understand, but
   I *can* understand it.
2- Since we don't allow (\` (a (\, 1 2 3))), it's weird to allow
   ``(a ,,@x) since one possible expansion for it when x=(1 2 3) is
   (\` (a (\, 1 2 3))).
   Another way to say it is that we should allow (\, 1 2 3) and (\,@
   1 2 3), but that can't be used with the ,e and ,@e syntax, so it'll
   stay as a second-rate citizen.

Isn't the above the same as

   (defmacro once-only (names &rest body)
     (let ((gensyms (loop for n in names collect (gensym))))
       `(let (,@(loop for g in gensyms collect `(,g (gensym))))
         `(let (,@(list ,@(loop for g in gensyms for n in names collect ``(,,g 
,,n))))
           ,(let (,@(loop for n in names for g in gensyms collect `(,n ,g)))
              ,@body)))))


-- Stefan



reply via email to

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