unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Nic Ferrier <nferrier@ferrier.me.uk>
To: emacs-devel@gnu.org
Subject: macroexpand and progn
Date: Sun, 28 Sep 2014 11:52:37 +0100	[thread overview]
Message-ID: <87r3ywt3t6.fsf@ferrier.me.uk> (raw)

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	other threads:[~2014-09-28 10:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-28 10:52 Nic Ferrier [this message]
2014-09-28 16:32 ` macroexpand and progn Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r3ywt3t6.fsf@ferrier.me.uk \
    --to=nferrier@ferrier.me.uk \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).