fasl-write fails on (setf ..) GF calls

Willem Broekema <[email protected]> Fri, 2 Sep 2005 23:10:41 +0200
Newsgroups gmane.lisp.allegro
Message-ID <[email protected]>
Imagine a regular function F that calls a generic function (setf
BAR-GF). If F is compiled and then written to a fasl file using
excl:fasl-write, then an error will be thrown:

 Error: Object #<standard-method (setf common-lisp-user::bar-gf) (t t)>
 cannot be written to a compiled file unless an applicable method is defined
 on make-load-form.  [condition type: program-error]

However, now let F call (setf BAR-GF) indirectly, by having F call a
(normal or generic) function that in turn does (setf BAR-GF). In that
case, fasl-write of the compiled F succeeds.

I'm wondering why the fasl-writing of F fails in the former case, but
succeeds in the latter?

Thanks!
 - Willem

(defun (setf bar-f) (val x)
  (list :setf-bar-f val x))

(defgeneric (setf bar-gf) (val x)
  (:method (val x) (list :setf-bar-gf val x)))

(defun indirect-setf-bar-gf-f (val x)
  (setf (bar-gf x) val))

(defgeneric indirect-setf-bar-gf-gf (val x)
  (:method (val x) (setf (bar-gf x) val)))
    

(let ((f (compile nil `(lambda ()
			 (values (setf (bar-f 3) 2)
				 #+(or)(setf (bar-gf 3) 2) ;; error
				 (indirect-setf-bar-gf-f 1 2)
				 (indirect-setf-bar-gf-gf 1 2)
				 )))))
  
  (excl:fasl-write f "test.fasl" t t)
  (print (multiple-value-list
	  (funcall (car (excl:fasl-read "test.fasl"))))))