| 1 |
<?xml version="1.0" encoding="utf-8"?> |
| 2 |
<!DOCTYPE book [ |
| 3 |
<!ENTITY % eclent SYSTEM "ecl.ent"> |
| 4 |
%eclent; |
| 5 |
]> |
| 6 |
<book xmlns="http://docbook.org/ns/docbook" version="5.0" xml:lang="en"> |
| 7 |
<chapter xml:id="Program-development"> |
| 8 |
<title>Program Development Facilities</title> |
| 9 |
|
| 10 |
<section xml:id="The-stepper"> |
| 11 |
<title>The Stepper</title> |
| 12 |
<blockquote> |
| 13 |
<screen><indexterm role="fn"><primary>step</primary></indexterm>— Macro: <function>step</function> <varname>form</varname></screen> |
| 14 |
<para>Starts evaluating the <replaceable>form</replaceable> in the single-step mode. In this mode, before |
| 15 |
any form is evaluated, the Stepper will print the form and prompt the user for |
| 16 |
a Stepper command. The Stepper binds the two variables print-level |
| 17 |
and print-length both to <literal>2</literal>, so that the current form may not |
| 18 |
occupy too much space on the screen. A Stepper command will be executed when |
| 19 |
the user types the single character for the command followed by the required |
| 20 |
arguments, if any, and presses the newline key. If the user presses the |
| 21 |
newline key without having typed any character, then the Stepper will assume |
| 22 |
that the Stepper command <literal>n</literal> was abbreviated.</para> |
| 23 |
</blockquote> |
| 24 |
<para>The stepper commands are:</para> |
| 25 |
<variablelist> |
| 26 |
<varlistentry> |
| 27 |
<term><literal>Newline</literal></term> |
| 28 |
<listitem> |
| 29 |
<para>Next. Evaluates the current form in the single-step mode.</para> |
| 30 |
</listitem> |
| 31 |
</varlistentry> |
| 32 |
<varlistentry> |
| 33 |
<term><replaceable>:s</replaceable>, <replaceable>:skip</replaceable></term> |
| 34 |
<listitem> |
| 35 |
<para>Skip. Evaluates the current form in the ordinary mode. The single-step mode |
| 36 |
will be resumed at completion of the evaluation.</para> |
| 37 |
</listitem> |
| 38 |
</varlistentry> |
| 39 |
<varlistentry> |
| 40 |
<term><replaceable>:b</replaceable>, <replaceable>:back</replaceable></term> |
| 41 |
<listitem> |
| 42 |
<para>Backwards. Steps back to previous step form.</para> |
| 43 |
</listitem> |
| 44 |
</varlistentry> |
| 45 |
<varlistentry> |
| 46 |
<term><replaceable>:pr</replaceable>, <replaceable>:print</replaceable></term> |
| 47 |
<listitem> |
| 48 |
<para>Print. Pretty-prints the current form.</para> |
| 49 |
</listitem> |
| 50 |
</varlistentry> |
| 51 |
<varlistentry> |
| 52 |
<term><replaceable>:form</replaceable></term> |
| 53 |
<listitem> |
| 54 |
<para>Form. Return the current form. Nothing is done, but the current form is |
| 55 |
returned as the value of this command. As a consequence, it is printed by the |
| 56 |
top level in the usual way and saved in the variable <literal>*</literal>. The main |
| 57 |
purpose of this command is to allow the current form to be examined further by |
| 58 |
accessing <literal>*</literal>.</para> |
| 59 |
</listitem> |
| 60 |
</varlistentry> |
| 61 |
<varlistentry> |
| 62 |
<term><replaceable>:ret</replaceable>, <replaceable>:return</replaceable></term> |
| 63 |
<listitem> |
| 64 |
<para>Return. Return without evaluating the current form.</para> |
| 65 |
</listitem> |
| 66 |
</varlistentry> |
| 67 |
<varlistentry> |
| 68 |
<term><replaceable>:x</replaceable>, <replaceable>:exit</replaceable></term> |
| 69 |
<listitem> |
| 70 |
<para>Exit. Evaluates the current form and any other forms in the ordinary mode.</para> |
| 71 |
</listitem> |
| 72 |
</varlistentry> |
| 73 |
<varlistentry> |
| 74 |
<term><literal>?</literal></term> |
| 75 |
<listitem> |
| 76 |
<para>Help. Lists the commands.</para> |
| 77 |
</listitem> |
| 78 |
</varlistentry> |
| 79 |
</variablelist> |
| 80 |
</section> |
| 81 |
|
| 82 |
<section xml:id="Errors"> |
| 83 |
<title>Errors</title> |
| 84 |
<blockquote> |
| 85 |
<screen><indexterm role="vr"><primary>*break-enable*</primary></indexterm>— Variable: <varname>*break-enable*</varname></screen> |
| 86 |
<para>This variable is used to determine whether to enter the break loop (see Section |
| 87 |
5.4) when an error occurs. Even the function <literal>break</literal> checks this |
| 88 |
variable. Initially, this variable is set to <replaceable>T</replaceable>, and thus an error will |
| 89 |
invoke the break loop. If the value is (), functions that cause fatal |
| 90 |
errors, such as <literal> error</literal>, will just print an error message and control |
| 91 |
will return to the top-level loop (or to the current break loop, if already in |
| 92 |
the break loop). Functions that cause correctable errors, such as <literal> |
| 93 |
cerror</literal>, will print an error message and a “continue message”, and control |
| 94 |
will return to the next form. In &ECL;, backtrace is not part of an error |
| 95 |
message, but a break loop command will print backtrace. Therefore, if |
| 96 |
break-enable is (), no backtrace appears on the screen.</para> |
| 97 |
<para>When the break loop is entered, break-enable will be bound to |
| 98 |
().</para> |
| 99 |
</blockquote> |
| 100 |
</section> |
| 101 |
|
| 102 |
<section xml:id="The-break-loop"> |
| 103 |
<title>The Break Loop</title> |
| 104 |
<para>The break loop is a read-eval-print loop similar to the top-level loop. In |
| 105 |
addition to ordinary Lisp forms, the break loop accepts various commands with |
| 106 |
which the user can inspect and modify the state of the program execution. Each |
| 107 |
break loop command is identified with a keyword (i.e., a symbol in the |
| 108 |
<literal>keyword</literal> package). A break loop command is executed when the user inputs |
| 109 |
a list whose first element is the keyword that identifies the command. The |
| 110 |
rest of the list is the arguments to the command. They are evaluated before |
| 111 |
being passed to the command. If the command needs no arguments, then the user |
| 112 |
may input only the keyword. It is an error if the given keyword does not |
| 113 |
identify any command. Any other input to the break loop is regarded as an |
| 114 |
ordinary Lisp form; the form will be evaluated and the resulting values will be |
| 115 |
printed on the terminal.</para> |
| 116 |
<para>There can be several instances of the break loop at the same time, and each |
| 117 |
such instance is identified by a <emphasis>level number</emphasis>. When the break loop is |
| 118 |
entered during execution in the top-level loop, the break loop instance is |
| 119 |
given the level number 1. The break loop instance that is entered from the |
| 120 |
level <emphasis>n</emphasis> break loop is given the level number <replaceable>n</replaceable><literal>+1</literal>. The |
| 121 |
prompt of the level <emphasis>n</emphasis> break loop is <replaceable>n</replaceable><literal>+1</literal> consecutive |
| 122 |
<literal>></literal>'s, occasionally prefixed with the name of the current package.</para> |
| 123 |
<para>The break loop keeps track of the invocation sequence of functions (including |
| 124 |
special forms and macro expansion functions), which led up to the break loop |
| 125 |
from the previous break loop (or from the top-level loop, if the current break |
| 126 |
loop is level 1). The invocation sequence is maintained in a pushdown stack of |
| 127 |
<emphasis>events</emphasis>. An event consists of an <emphasis>event function</emphasis> and an |
| 128 |
<emphasis>event environment</emphasis>. An event function is:</para> |
| 129 |
<orderedlist numeration="arabic"> |
| 130 |
<listitem> |
| 131 |
<para>an interpreted (i.e., not compiled) function (global function, local function, lambda-expression, or closure),</para> |
| 132 |
</listitem> |
| 133 |
<listitem> |
| 134 |
<para>a special form within an interpreted function,</para> |
| 135 |
</listitem> |
| 136 |
<listitem> |
| 137 |
<para>a macro expansion function called from an interpreted function,</para> |
| 138 |
</listitem> |
| 139 |
<listitem> |
| 140 |
<para>a compiled function called from an interpreted function, or</para> |
| 141 |
</listitem> |
| 142 |
<listitem> |
| 143 |
<para>a compiled function called from another compiled function which |
| 144 |
was compiled while the <literal>safety</literal> optimize level is 3 or with a |
| 145 |
<literal>notinline</literal> declaration for the called function (see Chapter 7).</para> |
| 146 |
</listitem> |
| 147 |
</orderedlist> |
| 148 |
<para>An event is pushed on the event stack when execution of its event function |
| 149 |
begins, and is popped away at the completion of the execution. An event |
| 150 |
environment is the `environment' of the event function at the time the next |
| 151 |
event is pushed. Actually, an event environment is a pointer to the main stack |
| 152 |
of &ECL;. For each interpreted event function (i.e., event function in |
| 153 |
classes 1, 2, and 3), the pointer points to the first entry of the three |
| 154 |
contiguous main stack entries that hold the lexical environment of the event |
| 155 |
function. For each compiled event function (i.e., event function in classes 4 |
| 156 |
and 5), the pointer is set to the first entry of the main stack area that is |
| 157 |
used locally by the compiled code. In most cases, the first argument to the |
| 158 |
compiled function is saved in the first entry, the second argument in the |
| 159 |
second entry, and so on. The local variables of the function are allocated in |
| 160 |
the entries following the arguments. However, this is not always the case. |
| 161 |
Refer to Section 7.3 for variable allocations in compiled functions.</para> |
| 162 |
<para>By break level commands, the user can choose one of the events as the |
| 163 |
<emphasis>current event</emphasis>. If the current event function is an interpreted event |
| 164 |
function, then the break loop evaluates Lisp forms in the lexical environment |
| 165 |
retrieved from the event environment. In particular, local variables may be |
| 166 |
referenced by the variable names, local functions and local macros may be |
| 167 |
invoked as usual, established blocks may be exited from, and tags may be used |
| 168 |
as the destination of <literal>go</literal>. If the current function is a compiled |
| 169 |
function, Lisp forms are evaluated in the null environment.</para> |
| 170 |
<para>Within the break loop, each event is represented by the <emphasis>event symbol</emphasis>. |
| 171 |
The <replaceable>:backtrace</replaceable> command, for example, lists events in terms of their event |
| 172 |
symbols. If the event function is a named function (global or local) or a |
| 173 |
macro expansion function, then the function or macro name is used as the event |
| 174 |
symbol. If the event function is a special form, then the name of the special |
| 175 |
form is used. If the event function is a lambda-expression (or a closure), |
| 176 |
then the symbol lambda (or lambda-closure) is used.</para> |
| 177 |
<para>To suppress unnecessary information, the user can hide (or make invisible) some |
| 178 |
of the events. Invisible events do not appear in the backtrace, for example. |
| 179 |
Initially, only those events are invisible whose event symbols belong to the |
| 180 |
system internal package system. When the break loop is entered, the last |
| 181 |
visible event becomes the current event.</para> |
| 182 |
<para>The break loop commands are described below. Some of the commands allow |
| 183 |
abbreviation in the keywords that identify them. For example, the user may |
| 184 |
abbreviate <replaceable>:current</replaceable> as <replaceable>:c</replaceable>. The break loop commands return no values |
| 185 |
at all.</para> |
| 186 |
<blockquote> |
| 187 |
<screen><indexterm role="fn"><primary>:current</primary></indexterm>— Break Command: <function>:current</function></screen> |
| 188 |
<screen><indexterm role="fn"><primary>:c</primary></indexterm>— Break Command: <function>:c</function> <varname></varname></screen> |
| 189 |
<para>Prints the event symbol of the current event.</para> |
| 190 |
</blockquote> |
| 191 |
<blockquote> |
| 192 |
<screen><indexterm role="fn"><primary>:previous</primary></indexterm>— Break Command: <function>:previous</function> <varname>&optional</varname> <varname>n</varname></screen> |
| 193 |
<screen><indexterm role="fn"><primary>:p</primary></indexterm>— Break Command: <function>:p</function> <varname>&optional n</varname></screen> |
| 194 |
<para>Makes the <replaceable>n</replaceable>-th previous visible event the |
| 195 |
new current event. Invisible events are not counted. If there are |
| 196 |
less than <replaceable>n</replaceable> previous events, then the first visible event in the |
| 197 |
invocation sequence becomes the new current event. <replaceable>n</replaceable> must be a |
| 198 |
positive integer and the default is <literal>1</literal>.</para> |
| 199 |
</blockquote> |
| 200 |
<blockquote> |
| 201 |
<screen><indexterm role="fn"><primary>:next</primary></indexterm>— Break Command: <function>:next</function> <varname>&optional</varname> <varname>n</varname></screen> |
| 202 |
<screen><indexterm role="fn"><primary>:n</primary></indexterm>— Break Command: <function>:n</function> <varname>&optional n</varname></screen> |
| 203 |
<para>Makes the <replaceable>n</replaceable>-th next visible event the |
| 204 |
new current event. If there are less than <replaceable>n</replaceable> next events, |
| 205 |
then the last visible event in the invocation sequence |
| 206 |
becomes the new current event. <replaceable>n</replaceable> must be a positive integer and the |
| 207 |
default is <literal>1</literal>.</para> |
| 208 |
</blockquote> |
| 209 |
<blockquote> |
| 210 |
<screen><indexterm role="fn"><primary>:backtrace</primary></indexterm>— Break Command: <function>:backtrace</function></screen> |
| 211 |
<screen><indexterm role="fn"><primary>:b</primary></indexterm>— Break Command: <function>:b</function> <varname></varname></screen> |
| 212 |
<para>Prints the event symbols of all visible events in order. The symbol of |
| 213 |
the current event is printed |
| 214 |
in upper-case letters and the event symbols of other events are in lower-case.</para> |
| 215 |
</blockquote> |
| 216 |
<blockquote> |
| 217 |
<screen><indexterm role="fn"><primary>:help</primary></indexterm>— Break Command: <function>:help</function></screen> |
| 218 |
<screen><indexterm role="fn"><primary>:h</primary></indexterm>— Break Command: <function>:h</function> <varname></varname></screen> |
| 219 |
<para>Lists the break loop commands.</para> |
| 220 |
</blockquote> |
| 221 |
<blockquote> |
| 222 |
<screen><indexterm role="fn"><primary>:quit</primary></indexterm>— Break Command: <function>:quit</function> <varname>&optional</varname> <varname>n</varname></screen> |
| 223 |
<screen><indexterm role="fn"><primary>:q</primary></indexterm>— Break Command: <function>:q</function> <varname>&optional n</varname></screen> |
| 224 |
<para>Returns control to the level <replaceable>n</replaceable> break loop. If <replaceable>n</replaceable> is 0 or if <replaceable>n</replaceable> |
| 225 |
is omitted, then control will return to the top-level loop. <replaceable>n</replaceable> must be a |
| 226 |
non-negative integer smaller than the current break level.</para> |
| 227 |
</blockquote> |
| 228 |
<blockquote> |
| 229 |
<screen><indexterm role="fn"><primary>:continue</primary></indexterm>— Break Command: <function>:continue</function></screen> |
| 230 |
<screen><indexterm role="fn"><primary>:c</primary></indexterm>— Break Command: <function>:c</function> <varname></varname></screen> |
| 231 |
<para>Returns control to the caller of the break loop. If the break loop has been |
| 232 |
entered from <literal>cerror</literal>, <literal>cerror</literal> returns () as its value and |
| 233 |
control will resume at that point. Otherwise, this command returns control to |
| 234 |
the previous break loop (or to the top-level loop, if the current break level |
| 235 |
is <literal>1</literal>).</para> |
| 236 |
</blockquote> |
| 237 |
<blockquote> |
| 238 |
<screen><indexterm role="fn"><primary>:variables</primary></indexterm>— Break Command: <function>:variables</function></screen> |
| 239 |
<screen><indexterm role="fn"><primary>:v</primary></indexterm>— Break Command: <function>:v</function> <varname></varname></screen> |
| 240 |
<para>Prints the names of the bound variables in the current |
| 241 |
environment. To see the value of a bound variable, just type the |
| 242 |
variable name.</para> |
| 243 |
</blockquote> |
| 244 |
<blockquote> |
| 245 |
<screen><indexterm role="fn"><primary>:functions</primary></indexterm>— Break Command: <function>:functions</function></screen> |
| 246 |
<para>Prints the names of the local functions and local macros in the current |
| 247 |
environment. To see the definition of a local function or macro, use the |
| 248 |
function special form in the usual way. That is, <literal>(function <replaceable>name</replaceable>)</literal> |
| 249 |
will return the definition of the local function or macro whose name is |
| 250 |
<replaceable>name</replaceable>. Local functions and local macros may be invoked as usual.</para> |
| 251 |
</blockquote> |
| 252 |
<blockquote> |
| 253 |
<screen><indexterm role="fn"><primary>:blocks</primary></indexterm>— Break Command: <function>:blocks</function></screen> |
| 254 |
<para>Prints the names of the blocks established in the current environment. If a |
| 255 |
block <replaceable>block</replaceable> is established, then the <literal>return-from</literal> form |
| 256 |
<literal>(return-from <replaceable>block value</replaceable>)</literal> works as usual. That is, the block form |
| 257 |
that established <replaceable>block</replaceable> will return <replaceable>value</replaceable> as its value and control |
| 258 |
will resume at that point.</para> |
| 259 |
</blockquote> |
| 260 |
<blockquote> |
| 261 |
<screen><indexterm role="fn"><primary>:tags</primary></indexterm>— Break Command: <function>:tags</function></screen> |
| 262 |
<para>Prints the tags established in the current environment. If a tag <replaceable>tag</replaceable> is |
| 263 |
established, then the <literal>go</literal> form <literal>(go <replaceable>tag</replaceable>)</literal> works as usual. |
| 264 |
That is, control will resume at the position of <replaceable>tag</replaceable> in the surrounding |
| 265 |
<literal>tagbody</literal>.</para> |
| 266 |
</blockquote> |
| 267 |
<blockquote> |
| 268 |
<screen><indexterm role="fn"><primary>:local</primary></indexterm>— Break Command: <function>:local</function> <varname>&optional</varname> <varname>n</varname></screen> |
| 269 |
<screen><indexterm role="fn"><primary>:l</primary></indexterm>— Break Command: <function>:l</function> <varname>&optional n</varname></screen> |
| 270 |
<para>If <replaceable>n</replaceable> is <literal>0</literal> or if it is omitted, then this command prints the value |
| 271 |
stored in the main stack entry that is pointed to by the current event |
| 272 |
environment. <replaceable>n</replaceable> is an offset from that entry. If <replaceable>n</replaceable> is positive, |
| 273 |
then the value of the <emphasis>n</emphasis>-th next (i.e., toward the top of the main stack) |
| 274 |
entry is printed. If <replaceable>n</replaceable> is negative, then the value of the <replaceable>n</replaceable>-th |
| 275 |
previous (i.e., toward the bottom of the main stack) entry is printed. <replaceable>n</replaceable> |
| 276 |
must be an integer. It is an error if the specified entry does not lie between |
| 277 |
the bottom and the top of the stack.</para> |
| 278 |
</blockquote> |
| 279 |
<blockquote> |
| 280 |
<screen><indexterm role="fn"><primary>:hide</primary></indexterm>— Break Command: <function>:hide</function> <varname>symbol</varname></screen> |
| 281 |
<para>Hides all events whose event symbol is <replaceable>symbol</replaceable>. In particular, by |
| 282 |
<literal>:hide 'lambda</literal> and <literal>hide 'lambda-closure</literal>, all events become |
| 283 |
invisible whose event functions are lambda-expressions and closures, |
| 284 |
respectively. If the event symbol of the current event happens to be |
| 285 |
<replaceable>symbol</replaceable>, then the last previous visible event will become the new current |
| 286 |
event. <replaceable>symbol</replaceable> must be a symbol.</para> |
| 287 |
<para>Events of <literal>eval</literal> and <literal>evalhook</literal> may never become invisible and |
| 288 |
attempts to hide them are simply ignored. It is always the case that the first |
| 289 |
event function is either <literal>eval</literal> or <literal>evalhook</literal>. Keeping both of them |
| 290 |
visible is the simplest way to avoid the silly attempts of the user to hide all |
| 291 |
events.</para> |
| 292 |
</blockquote> |
| 293 |
<blockquote> |
| 294 |
<screen><indexterm role="fn"><primary>:hide-package</primary></indexterm>— Break Command: <function>:hide-package</function> <varname>package</varname></screen> |
| 295 |
<para>Hides all events whose event symbol belongs to the package |
| 296 |
<replaceable>package</replaceable>. <replaceable>package</replaceable> may be any object that represents a package, i.e., |
| 297 |
a package object, a symbol, or a string. If the event symbol of the current |
| 298 |
event happens to belong to the package <replaceable>package</replaceable>, then the last previous |
| 299 |
visible event will become the new current event. Even if <literal>lisp</literal> package |
| 300 |
was specified as <replaceable>package</replaceable>, events of <literal>eval</literal> and <literal>evalhook</literal> do |
| 301 |
not become invisible. See the description of <replaceable>:hide</replaceable> above.</para> |
| 302 |
</blockquote> |
| 303 |
<blockquote> |
| 304 |
<screen><indexterm role="fn"><primary>:unhide</primary></indexterm>— Break Command: <function>:unhide</function> <varname>symbol</varname></screen> |
| 305 |
<para><replaceable>:unhide</replaceable> is the inverse command of <replaceable>:hide</replaceable>. If, however, <replaceable> symbol</replaceable> |
| 306 |
belongs to one of the <replaceable>:hide-package</replaceable>d packages, events of <replaceable>symbol</replaceable> |
| 307 |
become visible only after the package is <literal>:unhide-package |
| 308 |
'd</literal>. <replaceable>symbol</replaceable> must be a symbol.</para> |
| 309 |
</blockquote> |
| 310 |
<blockquote> |
| 311 |
<screen><indexterm role="fn"><primary>:unhide-package</primary></indexterm>— Break Command: <function>:unhide-package</function> <varname>package</varname></screen> |
| 312 |
<para><replaceable>:unhide-package</replaceable> is the inverse command of <replaceable>:hide-package</replaceable>. However, an |
| 313 |
event whose event symbol belongs to <replaceable>package</replaceable> becomes visible only after |
| 314 |
the symbol is <literal>unhide 'd</literal>, if the symbol was <replaceable>:code 'd</replaceable> |
| 315 |
before. <replaceable>package</replaceable> may be any object that represents a package, i.e., a |
| 316 |
package object, a symbol, or a string.</para> |
| 317 |
</blockquote> |
| 318 |
<para>Example:</para> |
| 319 |
<para><screen> |
| 320 |
> (defun fact (x) (if (= x 0) one (* x (fact (1- x))))) |
| 321 |
fact ;;; Wrong definition for fact, the factorial. |
| 322 |
|
| 323 |
> (fact 6) ;;; Tries to calculate factorial 6. |
| 324 |
|
| 325 |
Error: The variable ONE is unbound. |
| 326 |
Error signalled by IF. |
| 327 |
|
| 328 |
Broken at IF: ;;; Enters the break-loop. |
| 329 |
>> :h ;;; Help. |
| 330 |
|
| 331 |
Break commands: |
| 332 |
:q(uit) Return to some previous break level. |
| 333 |
:pop Pop to previous break level. |
| 334 |
:c(ontinue) Continue execution. |
| 335 |
:b(acktrace) Print backtrace. |
| 336 |
:f(unction) Show current function. |
| 337 |
:p(revious) Go to previous function. |
| 338 |
:n(ext) Go to next function. |
| 339 |
:g(o) Go to next function. |
| 340 |
:fs Search forward for function. |
| 341 |
:bs Search backward for function. |
| 342 |
:v(ariables) Show local variables, functions, blocks, and tags. |
| 343 |
:l(ocal) Return the nth local value on the stack. |
| 344 |
:hide Hide function. |
| 345 |
:unhide Unhide function. |
| 346 |
:hp Hide package. |
| 347 |
:unhp Unhide package. |
| 348 |
:unhide-all Unhide all variables and packages. |
| 349 |
:vs Show value stack. |
| 350 |
:bds Show binding stack. |
| 351 |
:m(essage) Show error message. |
| 352 |
:hs Help stack. |
| 353 |
|
| 354 |
Top level commands: |
| 355 |
:cf Compile file. |
| 356 |
:exit or ^D Exit Lisp. |
| 357 |
:ld Load file. |
| 358 |
:step Single step form. |
| 359 |
:tr(ace) Trace function. |
| 360 |
:untr(ace) Untrace function. |
| 361 |
|
| 362 |
Help commands: |
| 363 |
:apropos Apropos. |
| 364 |
:doc(ument) Document. |
| 365 |
:h(elp) or ? Help. Type ":help help" for more information. |
| 366 |
|
| 367 |
>> :b ;;; Backtrace. |
| 368 |
Backtrace: eval > fact > if > fact > if > fact > if > fact > |
| 369 |
if > fact > if > fact > if > fact > IF |
| 370 |
|
| 371 |
>>: p ;;; Moves to the previous event. |
| 372 |
Broken at FACT. |
| 373 |
|
| 374 |
>> :b ;;; Now inside of fact but outside of if. |
| 375 |
Backtrace: eval > fact > if > fact > if > fact > if > fact > |
| 376 |
if > fact > if > fact > if > FACT > if |
| 377 |
|
| 378 |
>> :v ;;; Shows local variables. |
| 379 |
Local variables: |
| 380 |
X: 1 |
| 381 |
Block names: FACT. |
| 382 |
|
| 383 |
>> x ;;; The value of x is 1. |
| 384 |
1 |
| 385 |
|
| 386 |
>> (return-from fact 1) ;;; Returns from the fact block with value 1. |
| 387 |
720 ;;; Now the correct answer. |
| 388 |
|
| 389 |
> ;;; Top-level. |
| 390 |
</screen></para> |
| 391 |
</section> |
| 392 |
|
| 393 |
<section xml:id="Describe-and-inspect"> |
| 394 |
<title>Describe and Inspect</title> |
| 395 |
<blockquote> |
| 396 |
<screen><indexterm role="fn"><primary>describe</primary></indexterm>— Function: <function>describe</function> <varname>object</varname></screen> |
| 397 |
<para>Prints the information about <replaceable>object</replaceable> to the stream that is the value of |
| 398 |
<literal>*standard-output*</literal>. The description of an object consists of several |
| 399 |
fields, each of which is described in a recursive manner. For example, a |
| 400 |
symbol may have fields such as home package, variable documentation, value, |
| 401 |
function documentation, function binding, type documentation, <literal>deftype</literal> |
| 402 |
definition, properties.</para> |
| 403 |
</blockquote> |
| 404 |
<blockquote> |
| 405 |
<screen><indexterm role="fn"><primary>inspect</primary></indexterm>— Function: <function>inspect</function> <varname>object</varname></screen> |
| 406 |
<para>Prints the information about <replaceable>object</replaceable> in an interactive manner. The output |
| 407 |
of inspect is similar to that of <literal>describe</literal>, but after printing the label |
| 408 |
and the value of a field (the value itself is not <literal>describe 'd</literal>), it |
| 409 |
prompts the user to input a one-character command. The input to <literal>inspect</literal> |
| 410 |
is taken from the stream that is the value of <literal>*query-io*</literal>. Normally, the |
| 411 |
inspection of <replaceable>object</replaceable> terminates after all of its fields have been |
| 412 |
inspected. The following commands are supported:</para> |
| 413 |
<variablelist> |
| 414 |
<varlistentry> |
| 415 |
<term><literal>n</literal></term> |
| 416 |
<listitem> |
| 417 |
<para>Next. Goes to the next level; the field is inspected recursively.</para> |
| 418 |
</listitem> |
| 419 |
</varlistentry> |
| 420 |
<varlistentry> |
| 421 |
<term><literal>s</literal></term> |
| 422 |
<listitem> |
| 423 |
<para>Skip. Skips the inspection of the field. <literal>inspect</literal> proceeds to the next |
| 424 |
field.</para> |
| 425 |
</listitem> |
| 426 |
</varlistentry> |
| 427 |
<varlistentry> |
| 428 |
<term><literal>p</literal></term> |
| 429 |
<listitem> |
| 430 |
<para>Print. Pretty-prints the field and prompts again.</para> |
| 431 |
</listitem> |
| 432 |
</varlistentry> |
| 433 |
<varlistentry> |
| 434 |
<term><literal>u</literal> <replaceable>form</replaceable></term> |
| 435 |
<listitem> |
| 436 |
<para>Update. The <replaceable>form</replaceable> is evaluated and the field is replaced by the resulting |
| 437 |
value. If the field cannot be updated, the message <literal>Not updated.</literal> will |
| 438 |
be printed.</para> |
| 439 |
</listitem> |
| 440 |
</varlistentry> |
| 441 |
<varlistentry> |
| 442 |
<term><literal>a</literal></term> |
| 443 |
<listitem> |
| 444 |
<para>Abort. Aborts the inspection of the current object. The field and |
| 445 |
the rest of the fields are not inspected.</para> |
| 446 |
</listitem> |
| 447 |
</varlistentry> |
| 448 |
<varlistentry> |
| 449 |
<term><literal>e</literal> <replaceable>form</replaceable></term> |
| 450 |
<listitem> |
| 451 |
<para>Eval. Evaluates the specified form in the null environment and prints the |
| 452 |
resulting values. Then prompts again with the same field.</para> |
| 453 |
</listitem> |
| 454 |
</varlistentry> |
| 455 |
<varlistentry> |
| 456 |
<term><literal>q</literal></term> |
| 457 |
<listitem> |
| 458 |
<para>Quit. Aborts the entire inspection.</para> |
| 459 |
</listitem> |
| 460 |
</varlistentry> |
| 461 |
<varlistentry> |
| 462 |
<term><literal>?</literal></term> |
| 463 |
<listitem> |
| 464 |
<para>Help. Lists the <literal>inspect</literal> commands.</para> |
| 465 |
</listitem> |
| 466 |
</varlistentry> |
| 467 |
</variablelist> |
| 468 |
</blockquote> |
| 469 |
</section> |
| 470 |
|
| 471 |
<section xml:id="The-profiler"> |
| 472 |
<title>The Profiler</title> |
| 473 |
<para>The profiler tool is enabled by default in the basic &ECL; configuration. It |
| 474 |
can be disabled with the <literal>configure</literal> option <literal>--disable-profiler</literal>.</para> |
| 475 |
<blockquote> |
| 476 |
<screen><indexterm role="fn"><primary>profile</primary></indexterm>— sys: <function>profile</function> <varname>grain</varname> <varname>&optional</varname> <varname>address</varname></screen> |
| 477 |
<para>This function activates the profiling of subsequent executions. <replaceable>grain</replaceable> is |
| 478 |
a value between 1 and 16384 which indicates the granularity of code segments to |
| 479 |
consider. There is a counter for each such segment. With each clock tick, the |
| 480 |
current segment is identified and its corresponding histogram count is |
| 481 |
incremented. A value of 0 for <replaceable>grain</replaceable> means stop profiling. <replaceable>address</replaceable> |
| 482 |
indicates the base address for the code being profiled.</para> |
| 483 |
</blockquote> |
| 484 |
<blockquote> |
| 485 |
<screen><indexterm role="fn"><primary>display-profile</primary></indexterm>— sys: <function>display-profile</function></screen> |
| 486 |
<para>Displays the histogram of accumulated tick counts. The ticks are attributed to |
| 487 |
the compiled Lisp function whose base address is closest to the start of the |
| 488 |
segment. This may not be totally accurate for system functions which invoke |
| 489 |
some auxiliary function to do the job.</para> |
| 490 |
</blockquote> |
| 491 |
<blockquote> |
| 492 |
<screen><indexterm role="fn"><primary>clear-profile</primary></indexterm>— sys: <function>clear-profile</function></screen> |
| 493 |
<para>Clears the profile histogram.</para> |
| 494 |
</blockquote> |
| 495 |
<blockquote> |
| 496 |
<screen><indexterm role="vr"><primary>sys</primary></indexterm>— Variable: <varname>sys</varname> <type>*profile-array*</type></screen> |
| 497 |
<para>Contains the profile histogram: two short integer counters are packed in each |
| 498 |
value of this array of fixnums.</para> |
| 499 |
</blockquote> |
| 500 |
</section> |
| 501 |
|
| 502 |
<section xml:id="Online-help"> |
| 503 |
<title>Online Help</title> |
| 504 |
<para>Online help is provided by the following functions.</para> |
| 505 |
<blockquote> |
| 506 |
<screen><indexterm role="fn"><primary>help</primary></indexterm>— Function: <function>help</function> <varname>&optional symbol</varname></screen> |
| 507 |
<para><literal>help</literal> with no arguments prints a greeting message to &ECL; beginners. |
| 508 |
<literal>help</literal> with a symbol argument prints the documentation associated |
| 509 |
with the symbol.</para> |
| 510 |
</blockquote> |
| 511 |
<blockquote> |
| 512 |
<screen><indexterm role="fn"><primary>help*</primary></indexterm>— Function: <function>help*</function> <varname>string &optional package</varname></screen> |
| 513 |
<para>Prints the documentation associated with those symbols in the specified |
| 514 |
<replaceable>package</replaceable> whose print names contain <replaceable>string</replaceable> as substring. |
| 515 |
<replaceable>string</replaceable> may be a symbol, in which case the print name of that symbol is |
| 516 |
used. <replaceable>package</replaceable> is optional and defaults to the LISP package. |
| 517 |
If <replaceable>package</replaceable> is (), then all packages are searched.</para> |
| 518 |
</blockquote> |
| 519 |
</section> |
| 520 |
</chapter> |
| 521 |
<!-- Keep this comment at the end of the file |
| 522 |
Local variables: |
| 523 |
sgml-parent-document: "ecl.xml" |
| 524 |
sgml-indent-step: 1 |
| 525 |
nxml-child-indent: 1 |
| 526 |
nxml-outline-child-indent:1 |
| 527 |
fill-column: 79 |
| 528 |
End: |
| 529 |
--></book> |