From: Vladimir Zolotykh
Subject: defsetf, CMUCL, Cannot dump objects....
Date: 
Message-ID: <opsugu7mp34w83rv@algow.eurocom.od.ua>
Let me offer to your consideration the follwing simple and short file

--------------------------------------------------------------------------------
(defparameter *assoc* '(("asdf" . 2) ("jkl" . 4)))
(defun query (key &key (test #'equal))
   (cdr (assoc key *assoc* :test test)))
(defsetf query (key &key (test #'equal)) (new-val)
   `(let ((ent (assoc ,key *assoc* :test ,test)))
      (if ent
        (setf (cdr ent) ,new-val)
        (setq *assoc* (acons ,key ,new-val *assoc*)))))
(defun foo (key val)
   (setf (query key) val))
------------------------------------------------------------------------

It is not get compiled in CMUCL (19a), the error is

   Cannot dump objects of type FUNCTION into fasl files.

Is this my inability to use defsetf properly or some peculiarity of CMUCL
which I'm unaware of?

-- 
Vladimir Zolotykh

From: Kent M Pitman
Subject: Re: defsetf, CMUCL, Cannot dump objects....
Date: 
Message-ID: <u8xzv7x2x.fsf@nhplace.com>
"Vladimir Zolotykh" <······@eurocom.od.ua> writes:

> Let me offer to your consideration the follwing simple and short file
> 
> --------------------------------------------------------------------------------
> (defparameter *assoc* '(("asdf" . 2) ("jkl" . 4)))
> (defun query (key &key (test #'equal))
>    (cdr (assoc key *assoc* :test test)))
> (defsetf query (key &key (test #'equal)) (new-val)
>    `(let ((ent (assoc ,key *assoc* :test ,test)))
>       (if ent
>         (setf (cdr ent) ,new-val)
>         (setq *assoc* (acons ,key ,new-val *assoc*)))))
> (defun foo (key val)
>    (setf (query key) val))
> ------------------------------------------------------------------------
> 
> It is not get compiled in CMUCL (19a), the error is
> 
>    Cannot dump objects of type FUNCTION into fasl files.
> 
> Is this my inability to use defsetf properly or some peculiarity of CMUCL
> which I'm unaware of?

It's the fact that you're using #'equal as a value in a macro form.  It's
evaluating to a literal function object.  In the interpreter, this works
fine because such objects self-evaluate.  But it means it has to dump it to
a file when you compile it.  Try instead '#'equal as the default.
That way you won't be constructing macro forms like
 (assoc keyvar :test #<FUNCTION EQUAL>)
which is what your expansion looks like.  The #<...> should clue you to
"this might be problematic to dump".
With the extra quote you'll get
 (assoc keyvar :test #'equal)
which is what you wanted.
From: Vladimir Zolotykh
Subject: Re: defsetf, CMUCL, Cannot dump objects....
Date: 
Message-ID: <opsug6thex4w83rv@algow.eurocom.od.ua>
On Mon, 25 Jul 2005 14:55:54 GMT, Kent M Pitman <······@nhplace.com> wrote:

> Try instead '#'equal as the default.
Agreed, this fixes the problem in CMUCL.
Still I have one more point which I don't quite understand.
Why this file in its originally posted form is get compiled in ACL70  
without
any complaints? And a closely related question. If we speek about  
conforming
application should it use '#'equal or #'equal in this particular case ?



-- 
Vladimir Zolotykh
From: Kent M Pitman
Subject: Re: defsetf, CMUCL, Cannot dump objects....
Date: 
Message-ID: <uu0ii7lnr.fsf@nhplace.com>
"Vladimir Zolotykh" <······@eurocom.od.ua> writes:

> On Mon, 25 Jul 2005 14:55:54 GMT, Kent M Pitman <······@nhplace.com> wrote:
> 
> > Try instead '#'equal as the default.
> Agreed, this fixes the problem in CMUCL.
> Still I have one more point which I don't quite understand.
> Why this file in its originally posted form is get compiled in ACL70
> without
> any complaints? And a closely related question. If we speek about
> conforming
> application should it use '#'equal or #'equal in this particular case ?

To understand about dumping functions, read 
 http://www.lispworks.com/documentation/HyperSpec/Body/03_bd.htm
and its subsections about externalization of objects.

Implementations are permitted, but not required, to be able to externalize
certain objects, including functions. Some implementations output a function
by outputing a request to grab the current function from a function by the
same name upon load.  There are some philosophical issues in thus doing that
some might disagree with, which is why it's not required.
From: Joerg Hoehle
Subject: Re: defsetf, CMUCL, Cannot dump objects....
Date: 
Message-ID: <ud5p6hkim.fsf@users.sourceforge.net>
"Vladimir Zolotykh" <······@eurocom.od.ua> writes:

> It is not get compiled in CMUCL (19a), the error is
>    Cannot dump objects of type FUNCTION into fasl files.

> (defsetf query (key &key (test #'equal)) (new-val)

Try '#'equal instead of #'equal [untested]

Please think about how many times and when the keyword parameter gets
evaluated.

Regards,
	Jorg Hohle
Telekom/T-Systems Technology Center