From: Sam S. <sd...@gn...> - 2003-04-16 23:09:47
|
> * In message <sqa...@la...> > * On the subject of "[clisp-list] SBCL build, MAKE-LOAD-FORM, buglets" > * Sent on Thu, 10 Apr 2003 13:26:49 +0100 > * Honorable Christophe Rhodes <cs...@ca...> writes: > > At the toplevel, do > (defstruct foo a) > (defmethod make-load-form ((x foo) &optional env) > (make-load-form-saving-slots x :environment env)) > and put in a file, say foo.lisp: > (defvar *foo* '#S(FOO :A BAR)) > > Compile and load the file, and observe that *FOO* is correctly > initialized to a FOO structure whose A slot contains the symbol BAR. > So far, so good. Now, again at the toplevel, continuing the session, > do: > (makunbound '*foo*) > (defconstant bar 1) > and recompile and reload foo.lisp. Now I observe that *FOO* is bound > to #S(FOO :A 1) and not to #S(FOO :A BAR), which I believe is > incorrect behaviour. please try the appended patch. -- Sam Steingold (http://www.podval.org/~sds) running RedHat8 GNU/Linux <http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/> <http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html> Flying is not dangerous; crashing is. --- loadform.lisp.~1.4.~ 2001-08-20 16:52:13.000000000 -0400 +++ loadform.lisp 2003-04-16 18:57:18.000000000 -0400 @@ -31,34 +31,13 @@ (:method ((object standard-object) &optional environment) (make-load-form-saving-slots object :environment environment))) -(defun mlf-unquote (var form) - ;; replace '(... var ...) with `(... ,var ...) - ;; (setq v 10) - ;; (mlf-unquote 'v ''(1 (2 (b c) v d (a)))) ==> - ;; (LIST 1 (LIST 2 '(B C) V 'D '(A))) - (cond ((atom form) form) - ((eq (car form) 'quote) - (labels ((find-var (tree) - (if (atom tree) (eq var tree) - (or (find-var (car tree)) (find-var (cdr tree))))) - (unquote (form) - (if (consp form) - (if (find-var form) - (cons 'list (mapcar #'unquote form)) - (list 'quote form)) - (if (eq form var) form - (if (constantp form) form (list 'quote form)))))) - (unquote (cadr form)))) - (t (cons (mlf-unquote var (car form)) - (mlf-unquote var (cdr form)))))) - (defun mlf-init-function (object) (multiple-value-bind (cre-form ini-form) (make-load-form object) (if ini-form (let ((var (gensym))) `(lambda () (let ((,var ,cre-form)) - ,(mlf-unquote var (nsubst var object ini-form)) + ,(nsubst var object ini-form) ,var))) `(lambda () ,cre-form)))) |