Lisp HUG Maillist Archive

compile-file bug?

Unable to parse email body. Email id is 2420

Re: compile-file bug?

On Jun 4, 2004, at 6:27 AM, Nick Levine wrote:

> Consider the following two source files. The first one compiles
> fine. The second produces the error: #<function EQUAL 2019C2DA> is of
> type LOW:COMPILED-CODE which is not externalizable... But if I walk
> the (setf bar) form and compile that instead, no problems.
>
> Any thoughts? Sure looks like a bug to me.

Hi Nick,

The problem is that the macro definition actually ends up expanding 
into something with a literal function object in it, because the :test 
key defaults to the function #'equal. Try defaulting the :test 
parameter to 'equal instead of #'equal, or perhaps the s-expression 
'#'equal. Either of these would work. (and when in doubt, use 
macroexpand-1! :-)

Brian

>
> - nick
>
>
>
>
> ;;;;;;;;;;;   foo.lisp
>
> (in-package "CL-USER")
>
> (defvar *foo* nil)
>
> (defun foo (key value)
>   (let ((ent (assoc key *foo* :test #'equal)))
>     (if ent
>         (setf (cdr ent) value)
>       (push (cons key value) *foo*))
>     value))
>
> ;;;;;;;;;;;   bar.lisp
>
> (in-package "CL-USER")
>
> ;; Reduction of problems invoking portable webactions' (setf 
> request-query-value)
>
> (defvar *bar* nil)
>
> (defsetf bar (key &key (test #'equal)) (newvalue)
>   `(let ((ent (assoc ,key *bar* :test ,test)))
>     (if ent
>         (setf (cdr ent) ,newvalue)
>       (push (cons ,key ,newvalue) *bar*))
>     ,newvalue))
>
> (defun bar (key value)
>   (setf (bar key) value))
>
>
>
--
Brian Mastenbrook
bmastenb@cs.indiana.edu
http://cs.indiana.edu/~bmastenb/


Updated at: 2020-12-10 08:56 UTC