From: Jon Strait <jstrait@moonloop.net>
To: help-gnu-emacs@gnu.org
Subject: Expected behavior of CL special forms, 'labels' and 'flet', inside macros.
Date: Mon, 03 Aug 2009 01:04:44 -0700 [thread overview]
Message-ID: <4A769A1C.4050401@moonloop.net> (raw)
Hello,
I thought I'd run this issue by the list in case someone who's worked on
the CL extension code can say that it's the proper behavior and not
worth submitting a bug report on.
Basically, I tried using a 'labels' form to bind a function inside a
macro to be used recursively and it wasn't working. (Lisp nesting
exceeds max error) Then, I switched the 'labels' with 'flet', which
ended up working fine, but not until after having to change the binding
name as well. Using the same name for 'flet' as was previous used for
'labels' resulted in this strange error:
"Use `labels', not `flet', to rebind macro names"
Is seems for some reason, the 'labels' functions binding name was
registered with a macro name as well.
Be advised, this is only in the context of testing both the macro and
the calling code with eval-last-sexp inside a buffer.
For the sample macro I created below, the first argument is a list of
items and every subsequent argument is a lambda function taking one
argument, to apply in sequence to the initial argument list using mapcar:
(defmacro map-chain (init-list &rest mfuncs)
(setq mfuncs (reverse mfuncs))
(flet ((fmap (init-list mfuncs)
(if (null mfuncs)
init-list
`(mapcar ,(car mfuncs) ,(fmap init-list (cdr mfuncs))))))
(fmap init-list mfuncs)))
(map-chain '(7 8 9) (lambda (x) (* x 10)) (lambda (y) (+ y 4)))
I'm currently using Emacs 23.0.92
Thanks,
Jon
next reply other threads:[~2009-08-03 8:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-03 8:04 Jon Strait [this message]
[not found] <mailman.3797.1249343677.2239.help-gnu-emacs@gnu.org>
2009-08-04 1:49 ` Expected behavior of CL special forms, 'labels' and 'flet', inside macros Pascal J. Bourguignon
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A769A1C.4050401@moonloop.net \
--to=jstrait@moonloop.net \
--cc=help-gnu-emacs@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 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.