Using lisp displa to view local variables



On July 26, 2011, Stavros Makrakis wrote:
**************************
That all looks correct to me.  If you want something like (ldisplay x y z) 
to print x=3, y=3, etc., then ***ldisplay*** needs to be a macro.
****************************************
I have tried using  (dolist (xk xx)  body) with and without
(defmacro...) with no success. I obviously need to study up
on Lisp macros. Where do I put the commas when my
starting point is a lisp list like xx?
------------------------------------------------------------------
MAXIMA> (dolist (bk '(1 2 3))
                (print bk))

1
2
3
NIL

MAXIMA> (defun ldisplay (&rest xx)
      (dolist (xk xx) ($display_value xk)))

LDISPLAY

MAXIMA> (defun f1 ()
   (let ((a1 'aa) (s1 "my string") (l1 '(a b c)))
         (mtell "local")
         (ldisplay s1 l1 a1)
         (mtell "bye")))

F1

MAXIMA> (f1)

local
xk = my string
xk = (a, b, c)
xk = aa
bye
NIL

MAXIMA> (defmacro $ldisplay (&rest xx)
      (dolist (xk xx) ($display_value xk)))

$LDISPLAY

MAXIMA> (defun f1 ()
   (let ((a1 'aa) (s1 "my string") (l1 '(a b c)))
         (mtell "local")
         ($ldisplay s1 l1 a1)
         (mtell "bye")))

F1

MAXIMA> (f1)

local
xk = s1
xk = l1
xk = a1
bye
NIL

MAXIMA> (defmacro $ldisplay (&rest xx)
      (dolist (xk ,xx) ($display_value xk)))

Maxima encountered a Lisp error:
Error in READ [or a callee]: A comma has appeared out of a backquote.
 Error in EVAL [or a callee]: The variable XX is unbound.
Error in EVAL [or a callee]: The variable XK is unbound.

MAXIMA> (defmacro $ldisplay (&rest xx)
      (dolist (xk xx) ($display_value ,xk)))

Maxima encountered a Lisp error:
 Error in READ [or a callee]: A comma has appeared out of a backquote.
 Error in EVAL [or a callee]: The variable XK is unbound.

------------------------------------

Ted