[slime-devel] Re: defining LISP functions in Emacs
Tobias C. Rittweiler
tcr at freebits.de
Fri Jan 11 10:53:33 UTC 2008
Joe Corneli <jcorneli at planetmath.org> wrote on 2007-06-20:
> I am trying to continue on the quest I described before --
>
> "I want to create a variant of `defun' that takes arguments from
> Emacs and assembles a body to be evaluated by SLIME."
>
> ...
>
> Here is a macro that accomplishes this:
>
> (defmacro lefun (name arglist &rest body)
> `(defun ,name ,arglist
> (slime-eval (list (append (list 'lambda ',arglist) ',body) , at arglist))))
>
> Unfortunately, it still produces an error when I test it with the
> following code:
>
> (lefun myplus (a b) (+ a b))
> (myplus 2 3)
>
> Specifically, the above triggers SLDB with the following message:
>
> Execution of a form compiled with errors.
> Form:
> ((LAMBDA (A B) (+ A B)) 2 3)
> Compile-time error:
> illegal function call
>
> I do not know what this means.
Forms comming from Emacs to SWANK (the Common Lisp side of Slime) are
READ in the :SWANK-IO-PACKAGE, i.e. the form that was really evaluted in
Common Lisp looked liked this:
((SWANK-IO-PACKAGE::LAMBDA (A B) (SWANK-IO-PACKAGE::+ A B)) 2 3)
Which is not a valid form according to CL's evaluation model.
You have to send symbols to CL with an explicit package identifier:
(defmacro lefun (name arglist &rest body)
`(defun ,name ,arglist
(slime-eval (list (append (list 'cl:lambda ',arglist) ',body)
, at arglist))))
and
(lefun myplus (a b) (cl:+ a b))
HTH,
-T.
More information about the slime-devel
mailing list