all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Nathan Trapuzzano <nbtrap@nbtrap.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: Double unquote/unquote-splicing
Date: Mon, 04 Nov 2013 12:59:21 -0500	[thread overview]
Message-ID: <874n7sf3pi.fsf@nbtrap.com> (raw)
In-Reply-To: <jwv1u2wks69.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 04 Nov 2013 12:27:00 -0500")

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> 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.

We'll just have to disagree there.  But even granting that the latter is
easier to understand, I can't imagine anyone figuring out how to write
it from scratch.

> 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.

This is incorrect.  ``(a ,,@x) where x=(1 2 3) would evaluate to
(\` (a (\, 1) (\, 2) (\, 3))).  The first comma in ,,@ has the effect of
being applied member-wise to each element spliced out of ,@.  Cf. CLHS
`Backquote' (http://www.lispworks.com/documentation/HyperSpec/Body/02_df.htm).

> 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)))))

I believe so.  (FWIW, I don't think it's that easy to tell, though I'm
not great at this.  I derived the second form I presented from the first
form step-by-step using the rules in CLHS.)

The bottom line to me is that the behavior of Elisp differs from both CL
and Scheme, and there doesn't seem to be a good reason for it.

In further support of my argument :)

"The backquote syntax was particularly powerful when nested. This
occurred primarily within macro-defining macros; because such were coded
primarily by wizards, the ability to write and interpret nested
backquote expressions was soon surrounded by a certain mystique. Alan
Bawden of MIT acquired a particular reputation as backquote-meister in
the early days of the Lisp Machine." - "The Evolution of Lisp", Gabriel,
Steele.

I lifted that quote from a StackOverflow thread and have no idea whether
it's authentic.  But I think it's true.



  reply	other threads:[~2013-11-04 17:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-04 14:03 Double unquote/unquote-splicing Nathan Trapuzzano
2013-11-04 17:27 ` Stefan Monnier
2013-11-04 17:59   ` Nathan Trapuzzano [this message]
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=874n7sf3pi.fsf@nbtrap.com \
    --to=nbtrap@nbtrap.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.