[Openmcl-devel] Macro named λ won't expand in Slime REPL

Daniel Gackle danielgackle at gmail.com
Thu May 21 00:35:08 PDT 2009


Perhaps you are evaluating the (defmacro λ...) form in the REPL? That works
for me too. What doesn't work is loading a *file* with the (defmacro λ...)
and then trying to macroexpand a usage of λ in the REPL. Sorry I didn't make
that clear. Also, as I mentioned in replying to Matthew, the whole problem
goes away if we use a more normal name than λ. But λ is a nice name and we
haven't come up with anything better (FN seemed like a good candidate, but
turned out not to be).

Daniel


On Thu, May 21, 2009 at 12:53 AM, Stas Boukarev <stassats at gmail.com> wrote:

> Daniel Gackle <danielgackle at gmail.com> writes:
>
> > We defined a macro named λ (Greek lambda character, in case this email
> isn't Unicode-friendly) to expand into a lambda form, partly to
> > save typing and partly to add a couple extra features our system needs.
> This works fine when you compile files, but not in a Slime REPL or
> > when using the command slime-compile-defun. For example,
> >
> > (defun foo ()
> >   (λ (x) (1+ x)))
> >
> > works the way you'd expect if you compile the file it's in. But in the
> REPL bad things happen:
> >
> > (defun foo ()
> >    (λ (x) (1+ x)))
> > ;Compiler warnings :
> > ;   In FOO: Undefined function Λ
> > ;   In FOO: Undefined function X
> > ;   In FOO: Undeclared free variable X
> > => FOO
> >
> > (foo)
> > => Undefined function X called with arguments () .
> >    [Condition of type CCL::UNDEFINED-FUNCTION-CALL]
> >
> > (macroexpand '(λ (x) (1+ x)))
> >  => (Λ (X) (1+ X))
> >
> > And if you use slime-compile-defun on the (defun foo...) form, the
> following occurs:
> >
> > While compiling FOO :
> > #1=(X) is not a symbol or lambda expression in the form (#1# (1+ X)) .
> >    [Condition of type CCL::COMPILE-TIME-PROGRAM-ERROR]
> >
> > I'm posting this here because none of the above errors happen in SBCL, so
> there would seem to be something specific about the combination
> > of Slime and CCL that doesn't like this macro. Does anyone have any ideas
> or suggestions?
> >
> > Thank you,
> >
> > Daniel Gackle
> >
> Are you sure that your macro is defined?
> (defmacro λ (arguments &body body) `(lambda ,arguments , at body))
>
> (funcall (λ (x) (+ x 1)) 5) => 6
>
> Works fine here.
>
> --
> With best regards, Stas.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20090521/d1f743b3/attachment.htm>


More information about the Openmcl-devel mailing list