* macroexpand and progn
@ 2014-09-28 10:52 Nic Ferrier
2014-09-28 16:32 ` Stefan Monnier
0 siblings, 1 reply; 2+ messages in thread
From: Nic Ferrier @ 2014-09-28 10:52 UTC (permalink / raw)
To: emacs-devel
I am writing an Emacs-Lisp to Javascript compiler. As part of that I am
converting EmacsLisp to a condensed form of EmacsLisp, removing most of
the special forms and rewriting them as more general special forms.
When I come to replace progn with a function I started to get oddness.
I did some experiments:
(cl-defmacro nic-macroexpand-all-locally (form &environment env)
"Macroexpand things made with macrolet."
`(macroexpand-all ,form ',env))
(defun nic-translate (form)
(cl-macrolet ((progn (&rest body) `(nicblock ,body)))
(nic-macroexpand-all-locally form)))
(defun nic-translate2 (form)
(cl-macrolet ((prognblah (&rest body) `(blahblock ,body)))
(nic-macroexpand-all-locally form)))
(nic-translate '(progn (* 10 20))) => error void-function nic-block ???
(nic-translate2 '(prognblah (* 10 20))) => (blahblock ((* 10 20)))
In other words it looks like it's not possible to macro define `progn'.
Does anyone know if this is so and if so why?
I guess it won't be too much trouble for me, I can always add it to my
tiny Lisp language. But it's interesting.
Nic
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: macroexpand and progn
2014-09-28 10:52 macroexpand and progn Nic Ferrier
@ 2014-09-28 16:32 ` Stefan Monnier
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2014-09-28 16:32 UTC (permalink / raw)
To: Nic Ferrier; +Cc: emacs-devel
> In other words it looks like it's not possible to macro define `progn'.
Quite likely, indeed. I'd expect trouble when trying to define macros
for any of the special forms.
> Does anyone know if this is so and if so why?
Because they're called *special*-forms? ;-)
To make it work reliably, you'd probably need hygienic macros or packages.
Stefan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-09-28 16:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-28 10:52 macroexpand and progn Nic Ferrier
2014-09-28 16:32 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.