[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Expected behavior of CL special forms, 'labels' and 'flet', inside macro
Expected behavior of CL special forms, 'labels' and 'flet', inside macros.
Mon, 03 Aug 2009 01:04:44 -0700
Thunderbird 18.104.22.168 (X11/20090213)
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)
`(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
|[Prev in Thread]
||[Next in Thread]|
- Expected behavior of CL special forms, 'labels' and 'flet', inside macros.,
Jon Strait <=