From: Nathan Trapuzzano <nbtrap@nbtrap.com>
To: emacs-devel@gnu.org
Subject: Double unquote/unquote-splicing
Date: Mon, 04 Nov 2013 09:03:11 -0500 [thread overview]
Message-ID: <87wqko6z8g.fsf@nbtrap.com> (raw)
This was a subject of discussion not too long ago. Someone wrote to say
how unquote and unquote-splicing don't pile up properly (as in ,,@FORM
or ,@,@FORM). In fact, they do work properly in the case that the inner
unquote-splicing expands to just one form, but this is hardly a useful
case (it's easily re-writable in other terms). On the other hand, there
are useful cases of ,,@ and ,@,@ that cannot be written without
rendering the code virtually unreadable. Consider:
(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)))))
(defmacro once-only (names &rest body)
(let ((gensyms (loop for n in names collect (gensym))))
`(let (,@(loop for g in gensyms collect `(,g (gensym))))
(append (list `let)
(list (append
(list ,@(loop for g in gensyms for n in names
collect `(append (list ,g) (list ,n))))))
(list
(let (,@(loop for n in names for g in gensyms
collect `(,n ,g)))
,@body))))))
These two macros are semantically equivalent, but one is infinitely more
easy to read thanks to ,,@. However, only the latter form works in
Emacs when NAMES has length > 1.
For the sake of readability, I'd like to propose properly implementing
,,@ and ,@,@ etc. Is this doable without major changes to the current
backquote implementation? If so, is there some other reason why this
should _not_ be done?
Nathan
next reply other threads:[~2013-11-04 14:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-04 14:03 Nathan Trapuzzano [this message]
2013-11-04 17:27 ` Double unquote/unquote-splicing Stefan Monnier
2013-11-04 17:59 ` Nathan Trapuzzano
2013-11-04 18:11 ` Nathan Trapuzzano
2013-11-04 18:33 ` Stefan Monnier
2013-11-04 19:01 ` Drew Adams
2013-11-04 19:09 ` Nathan Trapuzzano
2013-11-04 20:41 ` Stefan Monnier
2013-11-05 15:03 ` Nathan Trapuzzano
2013-11-05 19:14 ` Stefan Monnier
2013-11-05 4:01 ` Stephen J. Turnbull
2013-11-05 15:22 ` Nathan Trapuzzano
2013-11-05 21:48 ` Stephen J. Turnbull
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wqko6z8g.fsf@nbtrap.com \
--to=nbtrap@nbtrap.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.