emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Why does evaluating a piece of Elisp code seemingly not expand a


From: Nick Dokos
Subject: Re: [O] Why does evaluating a piece of Elisp code seemingly not expand a macro?
Date: Fri, 15 Jan 2016 17:06:05 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

address@hidden (Samuel W. Flint) writes:

>>>>>> Marcin Borkowski writes:
>
> MB> This piece of code: #+BEGIN_SRC elisp :results value verbatim
> MB> :exports both (defmacro forty-two () (* 6 7))
>
> That is not a macro.  That's a function.  The return value of a macro
> (the result of the last expression in the implicit progn) needs to be a
> (quasi-)quoted expression.
>

Not so. 

> This macro simply evaluates to 42.  This should be a function.
>
Maybe it should be a function, but it *is* a macro:

--8<---------------cut here---------------start------------->8---
(defmacro forty-two () (* 6 7))
==> forty-two
(symbol-function 'forty-two)
==> (macro lambda nil (* 6 7))
--8<---------------cut here---------------end--------------->8---


> If you want a macro, you could have:
>
> #+BEGIN_SRC: emacs-lisp
>   (defmacro forty-two ()
>             '(* 6 7))
> #+END_SRC
>

That's a different macro:

--8<---------------cut here---------------start------------->8---
(defmacro forty-two () '(* 6 7))
==> forty-two
(symbol-function 'forty-two)
==> (macro lambda nil (quote (* 6 7)))
--8<---------------cut here---------------end--------------->8---

--
Nick





reply via email to

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