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

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

Re: How the backquote and the comma really work?


From: Marcin Borkowski
Subject: Re: How the backquote and the comma really work?
Date: Thu, 25 Jun 2015 20:06:46 +0200

On 2015-06-25, at 19:33, Michael Heerdegen <michael_heerdegen@web.de> wrote:

> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> So, I assume that when Emacs Lisp interpreter encounters a backquote
>
> It's even less mystical: backquote is just a normal macro:
>
>   C-h f ` RET

Thanks.  OTOH, backquote.el has more than 200 lines of code, and it is
a bit complicated (I would guess that it might contain some
optimizations/error checking/whatever).  Seeing a simplistic (though
working in typical/correct cases) version might be rather illuminating,
no?

> It's also a reader macro so that you can write
>
>   `thing
>
> as an abbreviation of of
>
>  (` thing)
>
> but that's just a detail.

Interesting.  Where is that defined?

>> 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?
>
> Seems to be a reasonable mental model.  Of course, the elements have
> already been read by the reader.  Whether these are evaluated or not
> depends on whether the macro finds the `backquote-unquote-symbol' in
> front of them, so to say.
>
>> so a bonus question is: can I find an Emacs Lisp metacircular
>> evaluator (taking into account the quoting mechanisms) anywhere?
>
> You don't need a meta thing, since backquote is completely implemented
> in Elisp, just read the source code ;-)

See above: it is pretty much complicated compared to entry-level stuff
in SICP.  (Though I guess that I will just put my shoulder to the wheel
and study the code.  That might lead to more questions;-).)

> Regards,
>
> Michael.

Thanks a lot,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



reply via email to

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