1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383
|
<html><head>
<title>Nyquist</title>
<style type="text/css">
.example {
color: #000000;
background-color: #F5F5F5;
padding: 8px;
border: #808080;
border-style: solid;
border-width: 1px;
width:auto;
}
.button {
color: #000000;
background-color: #F5F5F5;
padding-top: 1px;
padding-bottom: 1px;
padding-left: 4px;
padding-right: 8px;
border: #808080;
border-style: solid;
border-width: 1px;
white-space: pre;
}
.box {
color: #000000;
padding-top: 4px;
padding-bottom: 4px;
padding-left: 16px;
padding-right: 16px;
border: #808080;
border-style: solid;
border-width: 1px;
}
</style>
</head>
<body>
<a href="../start.htm">Nyquist / XLISP 2.0</a> -
<a href="../manual/contents.htm">Contents</a> |
<a href="tutorials.htm">Tutorials</a> |
<a href="../examples/examples.htm">Examples</a> |
<a href="../reference/reference-index.htm">Reference</a>
<hr>
<h1>Nyquist</h1>
<hr>
<ul>
<li><nobr><a href="#debugger-shortcuts">Debugger Shortcuts</a></nobr></li>
<li><nobr><a href="#grindef">grindef</a> - print the function definition of a closure</nobr></li>
<li><nobr><a href="#args">args</a> - print the argument list of a closure</nobr></li>
<li><nobr><a href="#setfn">setfn</a> - define 'alias' names for functions</nobr></li>
<li><nobr><a href="#display">display</a> - framework for debug messages</nobr></li>
</ul>
<p>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.</p>
<a name="debugger-shortcuts"></a>
<hr>
<h2>Debugger Shortcuts</h2>
<hr>
<p>Some Nyquist/XLISP debugger shortcuts, defined in 'xlinit.lsp' and
'misc.lsp':</p>
<p><table cellpadding="0" cellspacing="0"><tbody>
<tr>
<td><nobr><code> </code></nobr></td>
<td valign="top">
<table cellpadding="0" cellspacing="0" width="100%"><tbody>
<tr valign="top">
<td class="button"><nobr><code>(bt)</code></nobr></td>
</tr>
</tbody></table>
</td>
<td><nobr> → </nobr></td>
<td width="100%"><a href="../reference/baktrace.htm">baktrace</a></td>
</tr>
<tr>
<td height="2px"></td>
</tr>
<tr>
<td><nobr><code> </code></nobr></td>
<td valign="top">
<table cellpadding="0" cellspacing="0" width="100%"><tbody>
<tr valign="top">
<td class="button"><nobr><code>(co)</code></nobr></td>
</tr>
</tbody></table>
</td>
<td><nobr> → </nobr></td>
<td width="100%"><a href="../reference/continue.htm">continue</a></td>
</tr>
<tr>
<td height="2px"></td>
</tr>
<tr>
<td><nobr><code> </code></nobr></td>
<td valign="top">
<table cellpadding="0" cellspacing="0" width="100%"><tbody>
<tr valign="top">
<td class="button"><nobr><code>(top)</code></nobr></td>
</tr>
</tbody></table>
</td>
<td><nobr> → </nobr></td>
<td width="100%"><a href="../reference/top-level.htm">top-level</a></td>
</tr>
<tr>
<td><nobr><font size="-2"> </font></nobr></td>
</tr>
<tr>
<td><nobr><code> </code></nobr></td>
<td valign="top">
<table cellpadding="0" cellspacing="0" width="100%"><tbody>
<tr valign="top">
<td class="button"><nobr><code>(res)</code></nobr></td>
</tr>
</tbody></table>
</td>
<td><nobr> → </nobr></td>
<td width="100%"><a href="../reference/clean-up.htm">clean-up</a></td>
</tr>
<tr>
<td height="2px"></td>
</tr>
<tr>
<td><nobr><code> </code></nobr></td>
<td valign="top">
<table cellpadding="0" cellspacing="0" width="100%"><tbody>
<tr valign="top">
<td class="button"><nobr><code>(up)</code></nobr></td>
</tr>
</tbody></table>
</td>
<td><nobr> → </nobr></td>
<td width="100%"><a href="../reference/clean-up.htm">clean-up</a></td>
</tr>
</tbody></table></p>
<p>The debugger commands only work if
<a href="../reference/global-breakenable.htm">*breakenable*</a>
is <nobr>non-<a href="../reference/nil.htm">NIL</a></nobr>:</p>
<p><table cellpadding="0" cellspacing="0"><tbody>
<tr>
<td><nobr><code> </code></nobr></td>
<td valign="top">
<table cellpadding="0" cellspacing="0" width="100%"><tbody>
<tr valign="top">
<td class="button"><nobr><code>(bkon)</code></nobr></td>
</tr>
</tbody></table>
</td>
<td><nobr> → </nobr></td>
<td width="100%"><nobr>(setq
<a href="../reference/global-breakenable.htm">*breakenable*</a>
t)</nobr></td>
</tr>
<tr>
<td height="2px"></td>
</tr>
<tr>
<td><nobr><code> </code></nobr></td>
<td valign="top">
<table cellpadding="0" cellspacing="0" width="100%"><tbody>
<tr valign="top">
<td class="button"><nobr><code>(bkoff)</code></nobr></td>
</tr>
</tbody></table>
</td>
<td><nobr> → </nobr></td>
<td width="100%"><nobr>(setq
<a href="../reference/global-breakenable.htm">*breakenable*</a>
nil)</nobr></td>
</tr>
</tbody></table></p>
<p>You can make your own
<a href="../reference/global-tracenable.htm">*tracenable*</a>
shortcuts like shown here:</p>
<pre class="example">
(defun <font color="#0000CC">tron</font> ()
(setq <font color="#AA5500">*tracenable*</font> t))
(defun <font color="#0000CC">troff</font> ()
(setq <font color="#AA5500">*tracenable*</font> nil))
</pre>
<p>See also:</p>
<ul>
<li><nobr>XLISP 2.0 Manual → <a href="../manual/xlisp.htm#break-loop">Break Loop</a></nobr></li>
</ul>
<p><nobr> <a href="#top">Back to top</a></nobr></p>
<a name="grindef"></a>
<hr>
<h2>grindef</h2>
<hr>
<p>The 'grindef' function prints the Lisp code of a
<a href="../manual/xlisp.htm#data-types">closure</a> <nobr>[user-defined</nobr>
function or macro]:</p>
<pre class="example">
(defun <font color="#0000CC">grindef</font> (e)
(pprint (get-lambda-expression (symbol-function e))))
</pre>
<p>Example:</p>
<pre class="example">
> (grindef 'grindef)
(LAMBDA (E)
(PPRINT (GET-LAMBDA-EXPRESSION (SYMBOL-FUNCTION E))))
NIL
</pre>
<p><nobr> <a href="#top">Back to top</a></nobr></p>
<a name="args"></a>
<hr>
<h2>args</h2>
<hr>
<p>The 'args' function prints the name and the argument variables of a
<a href="../manual/xlisp.htm#data-types">closure</a> <nobr>[user-defined</nobr>
function or macro]:</p>
<pre class="example">
(defun <font color="#0000CC">args</font> (e)
(pprint (cons e (second (get-lambda-expression (symbol-function e))))))
</pre>
<p>Example:</p>
<pre class="example">
> (args 'args)
(ARGS E)
NIL
</pre>
<p><nobr> <a href="#top">Back to top</a></nobr></p>
<a name="setfn"></a>
<hr>
<h2>setfn</h2>
<hr>
<p>The 'setfn' macro defines 'alias' names for functions:</p>
<pre class="example">
(defmacro <font color="#0000CC">setfn</font> (a b)
`(setf (symbol-function ',a) (symbol-function ',b)))
</pre>
<p>Examples from 'xlinit.lsp':</p>
<pre class="example">
(setfn co continue)
(setfn top top-level)
(setfn res clean-up)
(setfn up clean-up)
</pre>
<p><nobr> <a href="#top">Back to top</a></nobr></p>
<a name="display"></a>
<hr>
<h2>display</h2>
<hr>
<p>'display' is a debugging macro, defined in 'xlinit.lsp'.</p>
<pre class="example">
(defmacro <font color="#0000CC">display-macro</font> (label &rest items)
(let ($res$)
(dolist ($item$ items)
(setq $res$ (cons
`(format t <font color="#880000">"~A = ~A "</font> ',$item$ ,$item$)
$res$)))
(append (list 'let nil `(format t <font color="#880000">"~A : "</font> ,label))
(reverse $res$)
'((terpri)))))
(defun <font color="#0000CC">display-on</font> ()
(setfn display display-macro) t)
(defun <font color="#0000CC">display-off</font> ()
(setfn display or) nil)
</pre>
<p>Usage:</p>
<pre class="example">
(display <font color="#880000">"heading"</font> <font color="#0000CC">var1 var2</font> ...)
</pre>
<p>expands into:</p>
<pre class="example">
(let ()
(format t "~A: " <font color="#880000">"heading"</font>)
(format t "~A = ~A " ',<font color="#0000CC">var1</font> ,<font color="#0000CC">var1</font>)
(format t "~A = ~A " ',<font color="#0000CC">var2</font> ,<font color="#0000CC">var2</font>)
... )
</pre>
<p>and then prints:</p>
<pre class="example">
<font color="#0000CC">heading</font> : <font color="#0000CC">VAR1</font> = <font color="#0000CC">value1 VAR2</font> = <font color="#0000CC">value2</font> ...
</pre>
<p>Using the 'display' macro in a function like shown here:</p>
<pre class="example">
(defun <font color="#0000CC">hello</font> ()
(let ((local-var 'hello))
(display <font color="#880000">"debug message"</font> local-var)
local-var)) <font color="#008844">; return value</font>
</pre>
<p>Now the '<nobr>debug message</nobr>' can be switched on and off without
changing the code:</p>
<pre class="example">
> (display-on)
T
> (hello)
debug message : LOCAL-VAR = HELLO
HELLO
> (display-off)
NIL
> (hello)
HELLO
</pre>
<p><nobr> <a href="#top">Back to top</a></nobr></p>
<hr>
<a href="../start.htm">Nyquist / XLISP 2.0</a> -
<a href="../manual/contents.htm">Contents</a> |
<a href="tutorials.htm">Tutorials</a> |
<a href="../examples/examples.htm">Examples</a> |
<a href="../reference/reference-index.htm">Reference</a>
</body></html>
|