This page will not save you from reading the Nyquist manual, it's a list of things I find useful but frequently have to look them up in the manuals when I haven't worked with Nyquist for a while. Many more useful tricks can be found in the 'Developing and Debugging in Nyquist' chapter in the Nyquist manual.
Some Nyquist/XLISP debugger shortcuts, defined in 'xlinit.lsp' and 'misc.lsp':
|
|
baktrace | ||
|
|
continue | ||
|
|
top-level | ||
|
|
clean-up | ||
|
|
clean-up |
The debugger commands only work if
*breakenable*
is
|
|
|||
|
|
You can make your own *tracenable* shortcuts like shown here:
(defun tron () (setq *tracenable* t)) (defun troff () (setq *tracenable* nil))
See also:
The 'grindef' function prints the Lisp code of a
closure
(defun grindef (e) (pprint (get-lambda-expression (symbol-function e))))
Example:
> (grindef 'grindef)
(LAMBDA (E)
(PPRINT (GET-LAMBDA-EXPRESSION (SYMBOL-FUNCTION E))))
NIL
The 'args' function prints the name and the argument variables of a
closure
(defun args (e) (pprint (cons e (second (get-lambda-expression (symbol-function e))))))
Example:
> (args 'args) (ARGS E) NIL
The 'setfn' macro defines 'alias' names for functions:
(defmacro setfn (a b) `(setf (symbol-function ',a) (symbol-function ',b)))
Examples from 'xlinit.lsp':
(setfn co continue) (setfn top top-level) (setfn res clean-up) (setfn up clean-up)
'display' is a debugging macro, defined in 'xlinit.lsp'.
(defmacro display-macro (label &rest items)
(let ($res$)
(dolist ($item$ items)
(setq $res$ (cons
`(format t "~A = ~A " ',$item$ ,$item$)
$res$)))
(append (list 'let nil `(format t "~A : " ,label))
(reverse $res$)
'((terpri)))))
(defun display-on ()
(setfn display display-macro) t)
(defun display-off ()
(setfn display or) nil)
Usage:
(display "heading" var1 var2 ...)
expands into:
(let () (format t "~A: " "heading") (format t "~A = ~A " ',var1 ,var1) (format t "~A = ~A " ',var2 ,var2) ... )
and then prints:
heading : VAR1 = value1 VAR2 = value2 ...
Using the 'display' macro in a function like shown here:
(defun hello ()
(let ((local-var 'hello))
(display "debug message" local-var)
local-var)) ; return value
Now the '
> (display-on) T > (hello) debug message : LOCAL-VAR = HELLO HELLO > (display-off) NIL > (hello) HELLO