[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: understanding backquote
From: |
Olaf Rogalsky |
Subject: |
Re: understanding backquote |
Date: |
Wed, 03 Jun 2015 00:53:17 +0200 |
>> I have problems in understanding the semantics of backquote. Consider
>> the following function:
...
> Backquote and comma operate at read time. The comma means "Don't quote
> this part", so it will be evaluated when the code is run. It doesn't get
> evaluated at read time, though, because that would mess up if it has
> variable references, e.g.
Ah, I always thought, that comma expressions are evaluated at read time.
> (defun test (a) `,(+ 1 a))
>
> If you looked at this function, it would have to be
>
> (lambda (a) (+ 1 a))
>
> It can't be folded at read time.
Yes, I thought this will produce an error.
The elisp manual does not make it totally clear, at which time comma
expressions are evaluated:
Chapter 9.4 Backquote:
Backquote constructs allow you to quote a list, but selectively
evaluate elements of that list. In the simplest case, it is identical
to the special form quote (described in the previous section; see
Quoting). For example, these two forms yield identical results:
`(a list of (+ 2 3) elements)
=> (a list of (+ 2 3) elements)
'(a list of (+ 2 3) elements)
=> (a list of (+ 2 3) elements)
The special marker ‘,’ inside of the argument to backquote indicates a
value that isn’t constant. The Emacs Lisp evaluator evaluates the
argument of ‘,’, and puts the value in the list structure:
Thanks for clarifying thing up for me.
Is there a way to evaluate parts of a defun during read-time or
byte-compile-time?
Olaf
- Re: gtags-find-tag and gtags-find-rtag in C-code, (continued)
- Message not available
Message not available
- Re: understanding backquote, Barry Margolin, 2015/06/02
- Re: understanding backquote,
Olaf Rogalsky <=
- Message not available
- Re: understanding backquote, Pascal J. Bourguignon, 2015/06/02
- Re: understanding backquote, Olaf Rogalsky, 2015/06/02
- Message not available
- Re: understanding backquote, Stefan Monnier, 2015/06/02
- Re: understanding backquote, Olaf Rogalsky, 2015/06/03
- Re: understanding backquote, Olaf Rogalsky, 2015/06/03
Message not availableRe: understanding backquote, Pascal J. Bourguignon, 2015/06/02