(let* ((m (mapcar #'car (gsp:sop (cadr p-split))))
(p (priority-values m))
(pairs (sort p #'<)))
(format t "M: ~A~%" m)
(format t "P: ~A~%" p)
(format t "PAIRS: ~A~%")
As you can see, I am looking for a command which will print out values
for me so I dont have to write these format statements.
--
terrence brannon ·······@rana.usc.edu telephones: home: 213-386-3659
3215 San Marino St. #7, LA, CA 90006 /o)\ office: 310-822-1511x308
http://rana.usc.edu:8376/~brannon \(o/ fax: 310-823-6714
;;; Debugging macro for tracing values inside of functions:
(defmacro trace-values (&rest sExpressions)
;; Expand to a format statement which prints out the form and value
;; of each s-expression in "sExpressions";
;; Any s-expression which is a string, is output verbatim;
`(format *trace-output*
,(with-output-to-string (formatString)
(format formatString "~~&")
(dolist (sexp sExpressions)
(if (stringp sexp)
(format formatString "~~A " sexp)
(format formatString "~S= ~~S " sexp)))
(format formatString "~~%"))
,@sExpressions) )
For example:
(trace-values "Printer Stuff:" *print-level* *print-length* "Whew~% " *print-array*)
Printer Stuff: *PRINT-LEVEL*= NIL *PRINT-LENGTH*= NIL Whew
*PRINT-ARRAY*= T
(trace-values *package* (package-name *Package*))
*PACKAGE*= #<The COMMON-LISP-USER package> (PACKAGE-NAME *PACKAGE*)= "COMMON-LISP-USER"
(macroexpand '(trace-values "Expand" (package-name *Package*)))
(FORMAT *TRACE-OUTPUT* "~&~A (PACKAGE-NAME *PACKAGE*)= ~S ~%" "Expand" (PACKAGE-NAME *PACKAGE*))
--
Thomas A. Russ, USC/Information Sciences Institute ···@isi.edu
Terrence M. Brannon wrote:
>
> (let* ((m (mapcar #'car (gsp:sop (cadr p-split))))
> (p (priority-values m))
> (pairs (sort p #'<)))
> (format t "M: ~A~%" m)
> (format t "P: ~A~%" p)
> (format t "PAIRS: ~A~%")
>
> As you can see, I am looking for a command which will print out values
> for me so I dont have to write these format statements.
> --
> terrence brannon ·······@rana.usc.edu telephones: home: 213-386-3659
> 3215 San Marino St. #7, LA, CA 90006 /o)\ office: 310-822-1511x308
> http://rana.usc.edu:8376/~brannon \(o/ fax: 310-823-6714
Try:
(defmacro VARS (&rest variables)
`(format *trace-output*
,(loop with result = "~&"
for var in variables
do
(setf result
(if (and (consp var)
(eq (first var) 'quote))
(concatenate 'string result " ~S ")
(concatenate 'string result (string-downcase var) " = ~S ")))
finally (return (concatenate 'string result "~%")))
,@variables))
Then:
(let* ((m (mapcar #'car (gsp:sop (cadr p-split))))
(p (priority-values m))
(pairs (sort p #'<)))
(vars m p pairs)
...etc...)