On July 22, 2011, Dieter Kaiser wrote:
**************************
The macro defmspec defines a special form of a Maxima function. One
possibility to use the function is to call Maximas evaluator directly:
.......
MAXIMA> (setq $form "This is my string")
"This is my string"
MAXIMA> (meval '(($display) $form))
form = "This is my string"
$DONE
**************************
Thanks for the suggestion. My actual goal is to create a
debug printout of selected local lisp variables
( and perhaps global Maxima level parameters?)
inside a lisp function, and have, for each variable or parameter,
the screen output ' name = current-value', as the maxima function
display does at the Maxima level. So instead of creating such
a lisp function from scratch, perhaps using displa, I thought
of trying to somehow use $display from the lisp level.
Your method produces a lisp error (shown below)
if used with a lisp parameter bound to a lisp list.
Also, I try to define a function with one argument which
uses your approach, but the attempt fails so far, even
when used with the lisp string variable.
--------
Maxima 5.24.0
using Lisp GNU Common Lisp (GCL) GCL 2.6.8 (a.k.a. GCL)
(%i1) display2d:false$
(%i2) a1 : aa1;
(%o2) aa1
(%i3) a2 : 10;
(%o3) 10
(%i4) to_lisp();
Type (to-maxima) to restart, ($quit) to quit Maxima.
MAXIMA> (setq s1 "My string")
"My string"
MAXIMA> (setq l1 '(1 2 3))
(1 2 3)
MAXIMA> (meval '(($display) $a1))
a1 = aa1
$DONE
MAXIMA> (meval '(($display) $a2))
a2 = 10
$DONE
MAXIMA> (meval '(($display) s1))
?s1 = "My string"
$DONE
MAXIMA> (meval '(($display) l1))
Maxima encountered a Lisp error:
Error in EVAL [or a callee]: Caught fatal error [memory may be damaged]
Automatically continuing.
To reenable the Lisp debugger set *debugger-hook* to nil.
MAXIMA> s1
"My string"
MAXIMA> (defun ldisplay1 (arg) (meval '(($display) arg)))
LDISPLAY1
MAXIMA> (ldisplay1 s1)
?arg = ?arg
$DONE
-----------------------------------
so clearly this function def doesn't work.
Can I finetune this approach to work, or
is their an easier way, or is there a lisp
analog to display2d which will do what I need
for quick debugging looks at current variable values
inside a lisp function. (I don't want to use
the debugger).
Ted