Subject: Well behaved post_eval_functions list (finally)
From: Wolfgang Jenkner
Date: Fri, 22 Apr 2005 17:25:07 +0200
I'd suggest to have only a generic hook in src and to load actual
implementations from share.
Changes to the maxima core:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~cut~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Index: macsys.lisp
===================================================================
RCS file: /cvsroot/maxima/maxima/src/macsys.lisp,v
retrieving revision 1.38
diff -u -r1.38 macsys.lisp
--- macsys.lisp 6 Mar 2005 20:49:26 -0000 1.38
+++ macsys.lisp 21 Apr 2005 17:27:33 -0000
@@ -42,7 +42,7 @@
;; they are caught by the macsyma-listener window process on
;; the lisp machine, or by setting the single toplevel process in Maclisp. -gjc
-(defmacro toplevel-macsyma-eval (x) `(meval* ,x))
+(declaim (special *toplevel-meval-hook*)) ;defined in suprv1
(defmvar $_ '$_ "last thing read in, cooresponds to lisp +")
;;Also defined in JPG;SUPRV
@@ -158,7 +158,7 @@
(setq time-before (get-internal-run-time)
etime-before (get-internal-real-time))
(setq area-before (used-area))
- (setq $% (toplevel-macsyma-eval $__))
+ (setq $% (funcall *toplevel-meval-hook* $__))
(setq etime-after (get-internal-real-time)
time-after (get-internal-run-time))
(setq area-after (used-area))
Index: suprv1.lisp
===================================================================
RCS file: /cvsroot/maxima/maxima/src/suprv1.lisp,v
retrieving revision 1.24
diff -u -r1.24 suprv1.lisp
--- suprv1.lisp 8 Apr 2005 15:58:11 -0000 1.24
+++ suprv1.lisp 21 Apr 2005 17:27:39 -0000
@@ -215,6 +215,8 @@
(meval test)
(clearsign))))
+(defvar *toplevel-meval-hook* #'meval*)
+
(defmfun makelabel (x)
(when (and $dskuse (not $nolabels) (> (setq dcount (f1+ dcount)) $filesize))
(setq dcount 0) (dsksave))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~cut~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(Another idea would be to replace (setq $% ...) by (mset '$% ...) and
to use an ASSIGN property for $%, but this would not be quite so
harmless, perhaps.)
A sample share package (using mostly your code):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~cut~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(in-package "MAXIMA")
(defmvar $post_eval_functions (make-mlist-simp))
(defun post-meval-hook (arg)
(setq $% (meval* arg))
(dolist (fun (margs $post_eval_functions) $%)
(setq $% (mfuncall fun $%))))
(defmfun $post_eval_install ()
(setq *toplevel-meval-hook* #'post-meval-hook))
(defmfun $post_eval_uninstall ()
(setq *toplevel-meval-hook* #'meval*)
(setq $post_eval_functions (make-mlist-simp)))
(defun post-eval-check-value (var value)
(unless (and ($listp value) (every 'symbolp (margs value)))
(mseterr var value)))
(putprop '$post_eval_functions #'post-eval-check-value 'assign)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~cut~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You have to explicitly call `post_eval_install()' at the beginning,
and instead of `kill(post_eval_functions)' do `post_eval_functions:[]'
(assigning a list of symbols to `post_eval_functions' is allowed and
expected, so IMHO there's not much point in using `kill', and
infolists might be a bit of a red herring here). Other than that,
things should work the same way as in your examples.
Wolfgang