emacs-devel
[Top][All Lists]
Advanced

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

macroexpand and progn


From: Nic Ferrier
Subject: macroexpand and progn
Date: Sun, 28 Sep 2014 11:52:37 +0100

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



reply via email to

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