Here is a possible solution for reset. This redefines defmvar to keep
track of the initial values. This is done by using a hashtable whose
key is the variable and whose value is the initial value. When reset
is called, we set all variables defined by defmvar to their initial
values.
I've tested this with clisp and CMUCL, and it appears to work
correctly.
This doesn't address the other issues mentioned in the bug report.
The code also assumes that the initial value is a constant of some
sort and not a function that is to be evaluated. If a variable isn't
a defmvar, then we don't reset it's value. Presumably, those
variables should have been defmvar's to begin with.
Ray
Index: src/commac.lisp
===================================================================
RCS file: /cvsroot/maxima/maxima/src/commac.lisp,v
retrieving revision 1.10
diff -u -r1.10 commac.lisp
--- src/commac.lisp 10 Jun 2002 03:39:19 -0000 1.10
+++ src/commac.lisp 1 Jul 2002 16:20:26 -0000
@@ -537,15 +537,20 @@
(defvar *reset-var* t)
+(defvar *variable-initial-values* (make-hash-table))
+
(defmacro defmvar (var &rest val-and-doc)
"If *reset-var* is true then loading or eval'ing will reset value, otherwise like defvar"
(cond ((> (length val-and-doc) 2)
(setq val-and-doc (list (car val-and-doc) (second val-and-doc)))))
`(progn
- #+lispm (si::record-source-file-name ',var 'defmvar)
- (defvar ,var ,@ val-and-doc)
- #+debug
- (maybe-reset ',var ',(if val-and-doc (list (car val-and-doc))))))
+ #+lispm (si::record-source-file-name ',var 'defmvar)
+ (unless (gethash ',var *variable-initial-values*)
+ (setf (gethash ',var *variable-initial-values*)
+ ,(first val-and-doc)))
+ (defvar ,var ,@ val-and-doc)
+ #+debug
+ (maybe-reset ',var ',(if val-and-doc (list (car val-and-doc))))))
(defun maybe-reset (var val-and-doc &aux val)
(cond (*reset-var*
Index: src/inmis.lisp
===================================================================
RCS file: /cvsroot/maxima/maxima/src/inmis.lisp,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 inmis.lisp
--- src/inmis.lisp 8 May 2000 06:09:41 -0000 1.1.1.1
+++ src/inmis.lisp 1 Jul 2002 16:20:26 -0000
@@ -78,7 +78,7 @@
;; I already fixed several bugs in it, but the +ITS version works fine on MC
;; and takes less address space. - JPG
(DECLARE-TOP(SPECIAL MODULUS $FPPREC))
-#-(or ITS Multics NIL) ;This version should be eventually used on Multics.
+#-(or cl ITS Multics NIL) ;This version should be eventually used on Multics.
(DEFMFUN $RESET ()
(SETQ *print-base* 10. *read-base* 10. ; *NOPOINT T
MODULUS NIL
@@ -95,3 +95,11 @@
;; *** with DEFMVAR. This is part of an older mechanism.
#+PDP10 (LOAD '((MACSYM) RESET FASL))
'$DONE)
+
+(defmfun $reset ()
+ (setq *print-base* 10.)
+ (setq *read-base* 10.)
+ (maphash #'(lambda (key val)
+ (format t "Resetting ~S to ~S~%" key val)
+ (setf (symbol-value key) val))
+ *variable-initial-values*))