toplevel-macsyma-eval, continue, and other fun stuff
Subject: toplevel-macsyma-eval, continue, and other fun stuff
From: C Y
Date: Tue, 15 Mar 2005 19:51:54 -0800 (PST)
Greetings all. I am trying to figure out where the "least dangerous"
place to put a call to a "lasteval" function would be. As near as I
can tell, the root of the maxima REPL is the function continue defined
in macsys.lisp on line 96. Within this function, there is this little
tidbit:
(setq $% (toplevel-macsyma-eval $__))
Clearly, this is referenced throughout Maxima - amusingly enough Maxima
still compiles if I comment out this definiton and replace $% with
(toplevel-macsyma-eval $__) in continue, but there are a large number
of test failures if I do. So "toplevel-macsyma-eval" isn't really, in
the sense that for a given input this level is reached during the
internal workings of many calculations. However, the only two places
this appears within the continue function are these two:
172 (set (setq d-tag (makelabel $outchar)) $%)
188 (if (eq (caar r) 'displayinput)
189 (displa `((mlable) ,d-tag ,$%)))
So here is my proposal - keep the definiton of $%, but in the top level
continue loop define something like the following:
(setq totaleval (lasteval(toplevel-macsyma-eval $__)))
and have the above lines read:
172 (set (setq d-tag (makelabel $outchar)) totaleval)
188 (if (eq (caar r) 'displayinput)
189 (displa `((mlable) ,d-tag ,totaleval)))
lasteval we can then define as a function which applies a user-defined
list of functions to what would have been the $% output. (That's the
part I don't really know how to do yet, although I imagine it should be
simple enough. Maybe something along the lines of:
(defun lasteval (listoffun arg)
(cond
((null listoffun) (arg))
((lasteval (cdr listoffun)((car listoffun) arg)))))
would work, whatever the legal form of that is.
CY
__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/