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

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

Re: understanding backquote


From: Nicolas Richard
Subject: Re: understanding backquote
Date: Wed, 03 Jun 2015 13:05:51 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Olaf Rogalsky <olaf.rogalsky@aol.de> writes:
> (defun test () `,(* (+ 1 2) (+ 3 4)))
>
> Now let's have a look at the defintion of the symbol:
>
> (symbol-function 'test)
> => (lambda nil (* (+ 1 2) (+ 3 4))) 
> Huhh???

I agree with your surprise.

>         I was thinking, that the above definition is equivalent to the
> following:
>
> (defun test () 21)

But mine goes in the opposite direction :
(defun test () `,(* (+ 1 2) (+ 3 4)))
should yield
(symbol-function 'test)
 => (lambda nil (\` (\, (* (+ 1 2) (+ 3 4)))))

However, evaluating with C-x C-e or C-M-x gives what you mentionned:
(lambda nil (* (+ 1 2) (+ 3 4)))

*But* if you evaluate the defun with M-:, then we get what I expected.

Why is that ? Because of eager macroexpansion (see
http://article.gmane.org/gmane.emacs.help/103223).

As another example, hitting C-x C-e after:
(defun foo (bar)
  (eval-when-compile
    (message "bar")))
will produce "bar" in your *Messages* buffer, but it doesn't happen
using M-:.

HTH,

-- 
Nico



reply via email to

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