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

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

How the backquote and the comma really work?


From: Marcin Borkowski
Subject: How the backquote and the comma really work?
Date: Thu, 25 Jun 2015 19:09:11 +0200

Hi all,

I decided that the time has come that I finally approach the scary
backquote-comma duo.  (While I understand it superficially, I’d like to
get it right and thoroughly this time.)  So my question is whether my
mental model (see below) is correct.

So, I assume that when Emacs Lisp interpreter encounters a backquote, it
looks at the expression after it.  If it is anything but a list, it just
works like the usual quote, and the backquoted expression evaluates to
what was backquoted.

If it is a list, its element are read and scanned.  If any part of the
list (probably a nested one) begins with a comma, the whole thing after
the comma (be it a symbol, a list or whatever) is evaluated as usual,
and the result is put into the resulting list.

Whew.  Is that (more or less) right?  (I am aware that I didn’t take
into account the splicing operator, but it doesn’t introduce a lot of
additional complexity) Of course, when writing it, I realized that my
natural-language description is not extremely precise, so a bonus
question is: can I find an Emacs Lisp metacircular evaluator (taking
into account the quoting mechanisms) anywhere?

And I know that I risk starting another thread lasting for dozens of
messages;-) – but I /do/ want to understand this stuff...  In fact, in
the spirit of another recent discussion, I want to write a simple code
analyzer, finding one-legged ‘if’s and suggesting replacing them with
‘when’s or ‘unless’es.  This is trivial unless (pun intended) you want
to take (back)quotes into consideration.

Best regards,

-- 
Marcin Borkowski               This email was proudly sent
http://mbork.pl                from my Emacs.



reply via email to

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