Debian Codegraph @

docsrc/xlisp/xlisp-doc/manual/part15.html

raw
1 <html><head><title>Appendix 3: XLISP: An Object-oriented Lisp</title></head>
2 <a name = "100"><h2>Appendix 3: XLISP: An Object-oriented Lisp</h2></a>
3
4 <blockquote><b>Version 2.0</b>
5 <p>
6 February 6, 1988
7 <p>
8 by<br>
9
10 <b>David Michael Betz</b><br>
11
12 127 Taylor Road<br>
13
14 Peterborough, NH 03458
15 <p>
16 (603) 924-6936 (home)
17 <p>
18 Copyright (c) 1988, by David Michael Betz<br>
19
20 All Rights Reserved<br>
21
22 Permission is granted for unrestricted non-commercial use<br>
23
24 </blockquote>
25
26
27 <a name = "101"><h3>Introduction</h3></a>
28 <p>
29 XLISP is an experimental programming language combining some of
30 the features of Common Lisp with an object-oriented extension
31 capability. It was implemented to allow experimentation with
32 object-oriented programming on small computers.
33 <p>
34 There are currently implementations of XLISP running on the IBM-
35 PC and clones under MS-DOS, on the Macintosh, the Atari-ST and
36 the Amiga. It is completely written in the programming language
37 C and is easily extended with user written built-in functions
38 and classes. It is available in source form to non-commercial
39 users.
40 <p>
41 Many Common Lisp functions are built into XLISP. In addition,
42 XLISP defines the objects Object and Class as primitives.
43 Object is the only class that has no superclass and hence is
44 the root of the class hierarchy tree. Class is the class of
45 which all classes are instances (it is the only object that is
46 an instance of itself).
47 <p>
48 This document is a brief description of XLISP. It assumes some
49 knowledge of LISP and some understanding of the concepts of
50 object-oriented programming.
51 <p>
52 I recommend the book <i>Lisp</i> by Winston and Horn and published by
53 Addison Wesley for learning Lisp. The first edition of this
54 book is based on MacLisp and the second edition is based on
55 Common Lisp. XLISP will continue to migrate towards
56 compatibility with Common Lisp.
57 <p>
58 You will probably also need a copy of <i>Common Lisp: The
59 Language</i> by Guy L. Steele, Jr., published by Digital Press to
60 use as a reference for some of the Common Lisp functions that
61 are described only briefly in this document.
62 <p>
63 <a name = "102"><h3>A Note From The Author</h3></a> If you have any problems with XLISP, feel free to contact me [me being David Betz - RBD] for
64 help or advice. Please remember that since XLISP is available
65 in source form in a high level language, many users [e.g. that Dannenberg fellow - RBD] have been
66 making versions available on a variety of machines. If you call
67 to report a problem with a specific version, I may not be able
68 to help you if that version runs on a machine to which I don't
69 have access. Please have the version number of the version that
70 you are running readily accessible before calling me.
71 <p>
72 If you find a bug in XLISP, first try to fix the bug yourself
73 using the source code provided. If you are successful in fixing
74 the bug, send the bug report along with the fix to me. If you
75 don't have access to a C compiler or are unable to fix a bug,
76 please send the bug report to me and I'll try to fix it.
77 <p>
78 Any suggestions for improvements will be welcomed. Feel free to
79 extend the language in whatever way suits your needs. However,
80 PLEASE DO NOT RELEASE ENHANCED VERSIONS WITHOUT CHECKING WITH ME
81 FIRST!! I would like to be the clearing house for new features
82 added to XLISP. If you want to add features for your own
83 personal use, go ahead. But, if you want to distribute your
84 enhanced version, contact me first. Please remember that the
85 goal of XLISP is to provide a language to learn and experiment
86 with LISP and object-oriented programming on small computers. I
87 don't want it to get so big that it requires megabytes of memory
88 to run.
89 <p>
90 <a name = "103"><h3>XLISP Command Loop</h3></a><a name="index664"><a name="index665"> When XLISP is started, it first tries to load the workspace
91 <code>xlisp.wks</code> from the current directory. If that file doesn't
92 exist, XLISP builds an initial workspace, empty except for the
93 built-in functions and symbols.
94 <p>
95 Then XLISP attempts to load <code>init.lsp</code> from the current
96 directory. It then loads any files named as parameters on the
97 command line (after appending <code>.lsp</code> to their names).
98 <p>
99 XLISP then issues the following prompt:
100 <pre>
101 &gt
102 </pre>
103
104 This indicates that XLISP is waiting for an expression to be
105 typed.
106 <p>
107 When a complete expression has been entered, XLISP attempts to
108 evaluate that expression. If the expression evaluates
109 successfully, XLISP prints the result and then returns to the
110 initial prompt waiting for another expression to be typed.
111 <p>
112 <a name = "104"><h3>Break Command Loop</h3></a><a name="index666"> When XLISP encounters an error while evaluating an expression,
113 it attempts to handle the error in the following way:
114 <p>
115 If the symbol <code>*breakenable*<a name="index667"></code> is true, the message corresponding
116 to the error is printed. If the error is correctable, the
117 correction message is printed.
118 <p>
119 If the symbol <code>*tracenable*<a name="index668"></code> is true, a trace back is printed.
120 The number of entries printed depends on the value of the symbol
121 <code>*tracelimit*<a name="index669"></code>. If this symbol is set to something other than a
122 number, the entire trace back stack is printed.
123 <p>
124 XLISP then enters a read/eval/print loop to allow the user to
125 examine the state of the interpreter in the context of the
126 error. This loop differs from the normal top-level
127 read/eval/print loop in that if the user invokes the function
128 <code>continue</code>, XLISP will continue from a correctable error. If
129 the user invokes the function <code>clean-up</code>, XLISP will abort the
130 break loop and return to the top level or the next lower
131 numbered break loop. When in a break loop, XLISP prefixes the
132 break level to the normal prompt.
133 <p>
134 If the symbol <code>*breakenable*<a name="index670"></code> is <code>nil</code>, XLISP looks for a
135 surrounding errset function. If one is found, XLISP examines
136 the value of the print flag. If this flag is true, the error
137 message is printed. In any case, XLISP causes the errset
138 function call to return <code>nil</code>.
139 <p>
140 If there is no surrounding errset function, XLISP prints the
141 error message and returns to the top level.
142 <p>
143 <a name = "105"><h3>Data Types</h3></a><a name="index671"><a name="index672"> There are several different data types available to XLISP
144 programmers.
145 <p>
146 <ul>
147 <li>
148 lists
149 <li>symbols
150 <li>strings
151 <li>integers
152 <li>characters
153 <li>floats
154 <li>objects
155 <li>arrays
156 <li>streams
157 <li>subrs (built-in functions)
158 <li>fsubrs (special forms)
159 <li>closures (user defined functions)
160 </ul>
161 <p>
162 <a name = "106"><h3>The Evaluator</h3></a><a name="index673"><a name="index674"> The process of evaluation in XLISP:
163 <ul>
164 <li>
165 Strings, integers, characters, floats, objects, arrays, streams,
166 subrs, fsubrs and closures evaluate to themselves.
167 <li> Symbols act as variables and are evaluated by retrieving the
168 value associated with their current binding.
169 <li> Lists are evaluated by examining the first element of the list
170 and then taking one of the following actions:
171 <ul>
172 <li>
173 If it is a symbol, the functional binding of the symbol is
174 retrieved.
175 <li> If it is a lambda expression, a closure is constructed for
176 the function described by the lambda expression.
177 <li> If it is a subr, fsubr or closure, it stands for itself.
178 <li> Any other value is an error.
179 </ul>
180 Then, the value produced by the previous step is examined:
181 <ul>
182 <li>
183 If it is a subr or closure, the remaining list elements are
184 evaluated and the subr or closure is called with these
185 evaluated expressions as arguments.
186 <li> If it is an fsubr, the fsubr is called using the remaining
187 list elements as arguments (unevaluated).
188 <li> If it is a macro, the macro is expanded using the remaining
189 list elements as arguments (unevaluated). The macro
190 expansion is then evaluated in place of the original macro
191 call.
192 </ul>
193 </ul>
194 <p>
195 <a name = "107"><h3>Lexical Conventions</h3></a><a name="index675"><a name="index676"> The following conventions must be followed when entering XLISP
196 programs:
197 <p>
198 Comments in XLISP code begin with a semi-colon character and
199 continue to the end of the line.
200 <p>
201 Symbol names in XLISP can consist of any sequence of non-blank
202 printable characters except the following:
203 <pre>
204 ( ) ' ` , " ;
205 </pre>
206
207 Uppercase and lowercase characters are not distinguished within
208 symbol names. All lowercase characters are mapped to uppercase
209 on input.
210 <p>
211 Integer literals consist of a sequence of digits optionally
212 beginning with a <code>+</code> or <code>-</code>. The range of values an integer can
213 represent is limited by the size of a C <code>long</code> on the machine on
214 which XLISP is running.
215 <p>
216 Floating point literals consist of a sequence of digits
217 optionally beginning with a <code>+</code> or <code>-</code> and including an embedded
218 decimal point. The range of values a floating point number can
219 represent is limited by the size of a C <code>float</code> (<code>double</code> on
220 machines with 32 bit addresses) on the machine on which XLISP is
221 running.
222 <p>
223 Literal strings are sequences of characters surrounded by double
224 quotes. Within quoted strings the ``<code>\</code>'' character is used to
225 allow non-printable characters to be included. The codes
226 recognized are:
227 <ul>
228 <li>
229 <code>\\</code> means the character ``<code>\</code>''
230 <li><code>\n</code> means newline
231 <li><code>\t</code> means tab
232 <li><code>\r</code> means return
233 <li><code>\f</code> means form feed
234 <li><code>\nnn</code> means the character whose octal code is nnn
235 </ul>
236 <p>
237 <a name = "108"><h3>Readtables</h3></a><a name="index677"> The behavior of the reader is controlled by a data structure
238 called a <i>readtable</i>. The reader uses the symbol <code>*readtable*<a name="index678"></code> to
239 locate the current readtable. This table controls the
240 interpretation of input characters. It is an array with 128
241 entries, one for each of the ASCII character codes. Each entry
242 contains one of the following things:
243 <ul>
244 <li>
245 <code>NIL</code> - Indicating an invalid character
246 <li> <code>:CONSTITUENT</code> - Indicating a symbol constituent
247 <li> <code>:WHITE-SPACE</code> - Indicating a whitespace character
248 <li> <code>(:TMACRO . <i>fun</i>)</code> - Terminating readmacro
249 <li> <code>(:NMACRO . <i>fun</i>)</code> - Non-terminating readmacro
250 <li> <code>:SESCAPE</code> - Single escape character ('\')
251 <li> <code>:MESCAPE</code> - Multiple escape character ('|')
252 </ul>
253 <p>
254 In the case of <code>:TMACRO</code> and <code>:NMACRO</code>, the <i>fun</i> component is a
255 function. This can either be a built-in readmacro function or a
256 lambda expression. The function should take two parameters.
257 The first is the input stream and the second is the character
258 that caused the invocation of the readmacro. The readmacro
259 function should return <code>NIL</code> to indicate that the character should
260 be treated as white space or a value consed with <code>NIL</code> to indicate
261 that the readmacro should be treated as an occurence of the
262 specified value. Of course, the readmacro code is free to read
263 additional characters from the input stream.
264 <p>
265 XLISP defines several useful read macros:
266 <ul>
267 <li>
268 '<i>&ltexpr&gt</i> == (quote <i>&ltexpr&gt</i>)
269 <li> #'<i>&ltexpr&gt</i> == (function <i>&ltexpr&gt</i>)
270 <li> #(<i>&ltexpr&gt</i>...) == an array of the specified expressions
271 <li> #x<i>&lthdigits&gt</i> == a hexadecimal number (0-9,A-F)
272 <li> #o<i>&ltodigits&gt</i> == an octal number (0-7)
273 <li> #b<i>&ltbdigits&gt</i> == a binary number (0-1)
274 <li> #\<i>&ltchar&gt</i> == the ASCII code of the character
275 <li> #| ... |# == a comment
276 <li> #:<i>&ltsymbol&gt</i> == an uninterned symbol
277 <li> `<i>&ltexpr&gt</i> == (backquote <i>&ltexpr&gt</i>)
278 <li> ,<i>&ltexpr&gt</i> == (comma <i>&ltexpr&gt</i>)
279 <li> ,@<i>&ltexpr&gt</i> == (comma-at <i>&ltexpr&gt</i>)
280 <li></ul>
281 <a name = "109"><h3>Lambda Lists</h3></a><a name="index679"> There are several forms in XLISP that require that a ``lambda
282 list'' be specified. A lambda list is a definition of the
283 arguments accepted by a function. There are four different
284 types of arguments.
285 <p>
286 The lambda list starts with required arguments. Required
287 arguments must be specified in every call to the function.
288 <p>
289 The required arguments are followed by the &amp;optional arguments.
290 Optional arguments may be provided or omitted in a call. An
291 initialization expression may be specified to provide a default
292 value for an &amp;optional argument if it is omitted from a call.
293 If no initialization expression is specified, an omitted
294 argument is initialized to <code>NIL</code>. It is also possible to provide
295 the name of a <code>supplied-p</code> variable that can be used to
296 determine if a call provided a value for the argument or if the
297 initialization expression was used. If specified, the supplied-
298 p variable will be bound to T if a value was specified in the
299 call and <code>NIL</code> if the default value was used.
300 <p>
301 The &amp;optional arguments are followed by the &amp;rest argument. The
302 &amp;rest argument gets bound to the remainder of the argument list
303 after the required and &amp;optional arguments have been removed.
304 <p>
305 The &amp;rest argument is followed by the &amp;key arguments. When a
306 keyword argument is passed to a function, a pair of values
307 appears in the argument list. The first expression in the pair
308 should evaluate to a keyword symbol (a symbol that begins with a
309 ``<code>:</code>''). The value of the second expression is the value of the
310 keyword argument. Like &amp;optional arguments, &amp;key arguments can
311 have initialization expressions and supplied-p variables. In
312 addition, it is possible to specify the keyword to be used in a
313 function call. If no keyword is specified, the keyword obtained
314 by adding a ``<code>:</code>'' to the beginning of the keyword argument symbol
315 is used. In other words, if the keyword argument symbol is
316 <code>foo</code>, the keyword will be <code>':foo</code>.
317 <p>
318 The &amp;key arguments are followed by the &amp;aux variables. These
319 are local variables that are bound during the evaluation of the
320 function body. It is possible to have initialization
321 expressions for the &amp;aux variables.
322 <p>
323 Here is the complete syntax for lambda lists:
324 <blockquote>
325 (<i>rarg</i>...<br>
326
327 [&amp;optional [<i>oarg</i> | (<i>oarg</i> [<i>init</i> [<i>svar</i>]])]...]<br>
328
329 [&amp;rest <i>rarg</i>]<br>
330
331 [&amp;key<br>
332
333 [<i>karg</i> | ([<i>karg</i> | (<i>key</i> <i>karg</i>)] [<i>init</i> [<i>svar</i>]])]...<br>
334
335 &amp;allow-other-keys]<br>
336
337 [&amp;aux<br>
338
339 [<i>aux</i> | (<i>aux</i> [<i>init</i>])]...])
340 <p>
341 where:
342 <p>
343 <i>rarg</i> is a required argument symbol<br>
344
345 <i>oarg</i> is an &amp;optional argument symbol<br>
346
347 <i>rarg</i> is the &amp;rest argument symbol<br>
348
349 <i>karg</i> is a &amp;key argument symbol<br>
350
351 <i>key</i> is a keyword symbol<br>
352
353 <i>aux</i> is an auxiliary variable symbol<br>
354
355 <i>init</i> is an initialization expression<br>
356
357 <i>svar</i> is a supplied-p variable symbol<br>
358
359 </blockquote>
360 <p>
361 <a name = "110"><h3>Objects</h3></a><a name="index680"> Definitions:
362 <ul>
363 <li>
364 selector - a symbol used to select an appropriate method
365 <li>message - a selector and a list of actual arguments
366 <li>method - the code that implements a message
367 </ul>
368 Since XLISP was created to provide a simple basis for
369 experimenting with object-oriented programming, one of the
370 primitive data types included is <i>object</i>. In XLISP, an object
371 consists of a data structure containing a pointer to the
372 object's class as well as an array containing the values of the
373 object's instance variables.
374 <p>
375 Officially, there is no way to see inside an object (look at the
376 values of its instance variables). The only way to communicate
377 with an object is by sending it a message.
378 <p>
379 You can send a message to an object using the <code>send</code> function.
380 This function takes the object as its first argument, the
381 message selector as its second argument (which must be a symbol)
382 and the message arguments as its remaining arguments.
383 <p>
384 The <code>send</code> function determines the class of the receiving object
385 and attempts to find a method corresponding to the message
386 selector in the set of messages defined for that class. If the
387 message is not found in the object's class and the class has a
388 super-class, the search continues by looking at the messages
389 defined for the super-class. This process continues from one
390 super-class to the next until a method for the message is found.
391 If no method is found, an error occurs.
392 <p>
393 A message can also be sent from the body of a method by using
394 the current object, but the method lookup starts with the
395 object's superclass rather than its class. This allows a
396 subclass to invoke a standard method in its parent class even
397 though it overrides that method with its own specialized
398 version.
399 <p>
400 When a method is found, the evaluator binds the receiving object
401 to the symbol <code>self</code> and evaluates the method using the
402 remaining elements of the original list as arguments to the
403 method. These arguments are always evaluated prior to being
404 bound to their corresponding formal arguments. The result of
405 evaluating the method becomes the result of the expression.
406 <p>
407 <a name = "111"><h3>The ``Object'' Class</h3></a><a name="index681"><code>Object</code><a name="index682"> - the top of the class hierarchy.
408 <p>
409 Messages:
410 <dl>
411 <dt>
412 <code>:show<a name="index683"></code> - show an object's instance variables.
413 <dd>
414 returns - the object
415
416 <br>
417 <br><dt><code>:class<a name="index684"></code> - return the class of an object
418 <dd>
419 returns - the class of the object
420
421 <br>
422 <br><dt><code>:isnew<a name="index685"></code> - the default object initialization routine
423 <dd>
424 returns - the object
425 <br><dt>
426 <code>:sendsuper<a name="index686"></code> <i>sel</i> <i>args</i>... - send superclass a message
427 <dd>
428 <i>sel</i> - the message selector<br>
429 <i>args</i> - the message arguments<br>
430 returns - the result of sending the message
431
432 <br>
433 <br><dt>
434 </dl>
435 <p>
436 <a name = "112"><h3>The ``Class'' Class</h3></a><a name="index687"><code>Class<a name="index688"></code> - class of all object classes (including itself)
437 <p>
438 Messages:
439 <p>
440 <dl>
441 <dt>
442 :new<a name="index689"> - create a new instance of a class
443 <dd>
444 returns - the new class object
445
446 <br>
447 <br><dt> :isnew<a name="index690"> <i>ivars</i> [<i>cvars</i> [<i>super</i>]] - initialize a new class
448 <dd>
449 <i>ivars</i> - the list of instance variable symbols<br>
450 <i>cvars</i> - the list of class variable symbols<br>
451 <i>super</i> - the superclass (default is object)<br>
452 returns - the new class object
453
454 <br>
455 <br><dt> :answer<a name="index691"> <i>msg</i> <i>fargs</i> <i>code</i> - add a message to a class
456 <dd>
457 <i>msg</i> - the message symbol<br>
458 <i>fargs</i> - the formal argument list (lambda list)<br>
459 <i>code</i> - a list of executable expressions<br>
460 returns - the object
461
462 <br>
463 <br><dt>
464 </dl>
465 <p>
466 When a new instance of a class is created by sending the message
467 <code>:new</code> to an existing class, the message <code>:isnew</code> followed by
468 whatever parameters were passed to the <code>:new</code> message is sent to
469 the newly created object.
470 <p>
471 When a new class is created by sending the <code>:new</code> message to the
472 object <code>Class</code>, an optional parameter may be specified
473 indicating the superclass of the new class. If this parameter
474 is omitted, the new class will be a subclass of <code>Object</code>. A
475 class inherits all instance variables, class variables, and
476 methods from its super-class.
477 <p>
478 <a name = "113"><h3>Profiling</h3></a><a name="index692">
479 The Xlisp 2.0 release has been extended with a profiling facility, which counts how many times and where <code>eval</code> is executed. A separate count is maintained for each named function, closure, or macro, and a count indicates an <code>eval</code> in the immediately (lexically) enclosing named function, closure, or macro. Thus, the count gives an indication of the amount of time spent in a function, not counting nested function calls. The list of all functions executed is maintained on the global <code>*profile*</code> variable. These functions in turn have <code>*profile*</code> properties, which maintain the counts. The profile system merely increments counters and puts symbols on the <code>*profile*</code> list. It is up to the user to initialize data and gather results. Profiling is turned on or off with the <code>profile</code> function. Unfortunately, methods cannot be profiled with this facility.
480 <p>
481 <a name = "114"><h3>SYMBOLS</h3></a><a name="index693">
482 <ul>
483 <li>
484 <code>self</code> - the current object (within a method context)
485 <li><code>*obarray*<a name="index694"></code> - the object hash table
486 <li><code>*standard-input*<a name="index695"></code> - the standard input stream
487 <li><code>*standard-output*<a name="index696"></code> - the standard output stream
488 <li><code>*error-output*<a name="index697"></code> - the error output stream
489 <li><code>*trace-output*<a name="index698"></code> - the trace output stream
490 <li><code>*debug-io*<a name="index699"></code> - the debug i/o stream
491 <li><code>*breakenable*<a name="index700"></code> - flag controlling entering break loop on errors
492 <li><code>*tracelist*<a name="index701"></code> - list of names of functions to trace
493 <li><code>*tracenable*<a name="index702"></code> - enable trace back printout on errors
494 <li><code>*tracelimit*<a name="index703"></code> - number of levels of trace back information
495 <li><code>*evalhook*<a name="index704"></code> - user substitute for the evaluator function
496 <li><code>*applyhook*<a name="index705"></code> - (not yet implemented)
497 <li><code>*readtable*<a name="index706"></code> - the current readtable
498 <li><code>*unbound*<a name="index707"></code> - indicator for unbound symbols
499 <li><code>*gc-flag*<a name="index708"></code> - controls the printing of gc messages
500 <li><code>*gc-hook*<a name="index709"></code> - function to call after garbage collection
501 <li><code>*integer-format*<a name="index710"></code> - format for printing integers (``%d'' or ``%ld'')
502 <li><code>*float-format*<a name="index711"></code> - format for printing floats (``%g'')
503 <li><code>*print-case*<a name="index712"></code> - symbol output case (:upcase or :downcase)
504 </ul>
505 <p>
506 There are several symbols maintained by the read/eval/print
507 loop. The symbols <code>+</code>, <code>++</code>, and <code>+++</code> are bound to the most
508 recent three input expressions. The symbols <code>*</code>, <code>**</code> and <code>***</code>
509 are bound to the most recent three results. The symbol <code>-</code> is
510 bound to the expression currently being evaluated. It becomes
511 the value of <code>+</code> at the end of the evaluation.
512 <a name = "115"><h3>Evaluation Functions</h3></a><a name="index713">
513 <dl>
514 <dt>
515 (eval<a name="index714"> <i>expr</i>) - evaluate an xlisp expression
516 <dd>
517 <i>expr</i> - the expression to be evaluated<br>
518 returns - the result of evaluating the expression
519
520 <br>
521 <br><dt> (apply<a name="index715"> <i>fun</i> <i>args</i>) - apply a function to a list of arguments
522 <dd>
523 <i>fun</i> - the function to apply (or function symbol)<br>
524 <i>args</i> - the argument list<br>
525 returns - the result of applying the function to the arguments
526
527 <br>
528 <br><dt> (funcall<a name="index716"> <i>fun</i> <i>arg</i>...) - call a function with arguments
529 <dd>
530 <i>fun</i> - the function to call (or function symbol)<br>
531 <i>arg</i> - arguments to pass to the function<br>
532 returns - the result of calling the function with the arguments
533
534 <br>
535 <br><dt> (quote<a name="index717"> <i>expr</i>) - return an expression unevaluated
536 <dd>
537 <i>expr</i> - the expression to be quoted (quoted)<br>
538 returns - <i>expr</i> unevaluated
539
540 <br>
541 <br><dt> (function<a name="index718"> <i>expr</i>) - get the functional interpretation<dd>
542 <i>expr</i> - the symbol or lambda expression (quoted)<br>
543 returns - the functional interpretation<br>
544
545 <br><dt> (backquote<a name="index719"> <i>expr</i>) - fill in a template<dd>
546 <i>expr</i> - the template<br>
547 returns - a copy of the template with comma and comma-at<br>
548 expressions expanded
549
550 <br>
551 <br><dt> (lambda<a name="index720"> <i>args</i> <i>expr</i>...) - make a function closure<dd>
552 <i>args</i> - formal argument list (lambda list) (quoted)<br>
553 <i>expr</i> - expressions of the function body<br>
554 returns - the function closure<br>
555
556 <br><dt> (get-lambda-expression<a name="index721"> <i>closure</i>) - get the lambda expression<dd>
557 <i>closure</i> - the closure<br>
558 returns - the original lambda expression<br>
559
560 <br><dt> (macroexpand<a name="index722"> <i>form</i>) - recursively expand macro calls<dd>
561 <i>form</i> - the form to expand<br>
562 returns - the macro expansion<br>
563
564 <br><dt> (macroexpand-1<a name="index723"> <i>form</i>) - expand a macro call<dd>
565 <i>form</i> - the macro call form<br>
566 returns - the macro expansion<br>
567
568 <br><dt>
569 </dl><a name = "116"><h3>Symbol Functions</h3></a><a name="index724">
570 <dl>
571 <dt>
572 (set<a name="index725"> <i>sym</i> <i>expr</i>) - set the value of a symbol
573 <dd>
574 <i>sym</i> - the symbol being set<br>
575 <i>expr</i> - the new value<br>
576 returns - the new value<br>
577
578 <br><dt> (setq<a name="index726"> [<i>sym</i> <i>expr</i>]...) - set the value of a symbol
579 <dd>
580 <i>sym</i> - the symbol being set (quoted)<br>
581 <i>expr</i> - the new value<br>
582 returns - the new value<br>
583
584 <br><dt> (psetq<a name="index727"> [<i>sym</i> <i>expr</i>]...) - parallel version of setq
585 <dd>
586 <i>sym</i> - the symbol being set (quoted)<br>
587 <i>expr</i> - the new value<br>
588 returns - the new value<br>
589
590 <br><dt> (setf<a name="index728"> [<i>place</i> <i>expr</i>]...) - set the value of a field
591 <dd>
592 <i>place</i> - the field specifier (quoted):<br>
593 <dl><dd>
594 <i>sym</i> - set value of a symbol<br>
595 (car <i>expr</i>) - set car of a cons node<br>
596 (cdr <i>expr</i>) - set cdr of a cons node<br>
597 (nth <i>n</i> <i>expr</i>) - set nth car of a list<br>
598 (aref <i>expr</i> <i>n</i>) - set nth element of an array<br>
599 (get <i>sym</i> <i>prop</i>) - set value of a property<br>
600 (symbol-value <i>sym</i>) - set value of a symbol<br>
601 (symbol-function <i>sym</i>) - set functional value of a symbol<br>
602 (symbol-plist <i>sym</i>) - set property list of a symbol<br>
603 </dl>
604 <i>expr</i> - the new value<br>
605 returns - the new value<br>
606
607 <br><dt>
608
609 (defun<a name="index729"> <i>sym</i> <i>fargs</i> <i>expr</i>...) - define a function<br>
610 (defmacro<a name="index730"> <i>sym</i> <i>fargs</i> <i>expr</i>...) - define a macro
611
612 <dd>
613 <i>sym</i> - symbol being defined (quoted)<br>
614 <i>fargs</i> - formal argument list (lambda list) (quoted)<br>
615 <i>expr</i> - expressions constituting the body of the<br>
616 function (quoted)
617 returns - the function symbol<br>
618
619 <br><dt> (gensym<a name="index731"> [<i>tag</i>]) - generate a symbol
620 <dd>
621 <i>tag</i> - string or number<br>
622 returns - the new symbol<br>
623
624 <br><dt>(intern<a name="index732"> <i>pname</i>) - make an interned symbol
625 <dd>
626 <i>pname</i> - the symbol's print name string<br>
627 returns - the new symbol<br>
628
629 <br><dt> (make-symbol<a name="index733"> <i>pname</i>) - make an uninterned symbol
630 <dd>
631 <i>pname</i> - the symbol's print name string<br>
632 returns - the new symbol<br>
633
634 <br><dt> (symbol-name<a name="index734"> <i>sym</i>) - get the print name of a symbol
635 <dd>
636 <i>sym</i> - the symbol<br>
637 returns - the symbol's print name<br>
638
639 <br><dt> (symbol-value<a name="index735"> <i>sym</i>) - get the value of a symbol
640 <dd>
641 <i>sym</i> - the symbol<br>
642 returns - the symbol's value<br>
643
644 <br><dt> (symbol-function<a name="index736"> <i>sym</i>) - get the functional value of a symbol
645 <dd>
646 <i>sym</i> - the symbol<br>
647 returns - the symbol's functional value<br>
648
649 <br><dt> (symbol-plist<a name="index737"> <i>sym</i>) - get the property list of a symbol
650 <dd>
651 <i>sym</i> - the symbol<br>
652 returns - the symbol's property list<br>
653
654 <br><dt> (hash<a name="index738"> <i>sym</i> <i>n</i>) - compute the hash index for a symbol
655 <dd>
656 <i>sym</i> - the symbol or string<br>
657 <i>n</i> - the table size (integer)<br>
658 returns - the hash index (integer)<br>
659
660 <br><dt>
661 </dl><a name = "117"><h3>Property List Functions</h3></a><a name="index739">
662 <dl>
663 <dt>
664 (get<a name="index740"> <i>sym</i> <i>prop</i>) - get the value of a property
665 <dd>
666 <i>sym</i> - the symbol<br>
667 <i>prop</i> - the property symbol<br>
668 returns - the property value or <code>nil</code><br>
669
670 <br><dt> (putprop<a name="index741"> <i>sym</i> <i>val</i> <i>prop</i>) - put a property onto a property list
671 <dd>
672 <i>sym</i> - the symbol<br>
673 <i>val</i> - the property value<br>
674 <i>prop</i> - the property symbol<br>
675 returns - the property value<br>
676
677 <br><dt> (remprop<a name="index742"> <i>sym</i> <i>prop</i>) - remove a property
678 <dd>
679 <i>sym</i> - the symbol<br>
680 <i>prop</i> - the property symbol<br>
681 returns - <code>nil</code><br>
682
683 <br><dt>
684 </dl><a name = "118"><h3>Array Functions</h3></a><a name="index743">
685 <dl>
686 <dt>
687 (aref<a name="index744"> <i>array</i> <i>n</i>) - get the nth element of an array
688 <dd>
689 <i>array</i> - the array<br>
690 <i>n</i> - the array index (integer)<br>
691 returns - the value of the array element<br>
692
693 <br><dt> (make-array<a name="index745"> <i>size</i>) - make a new array
694 <dd>
695 <i>size</i> - the size of the new array (integer)<br>
696 returns - the new array<br>
697
698 <br><dt> (vector<a name="index746"> <i>expr</i>...) - make an initialized vector
699 <dd>
700 <i>expr</i> - the vector elements<br>
701 returns - the new vector<br>
702
703 <br><dt>
704 </dl><a name = "119"><h3>List Functions</h3></a><a name="index747">
705 <dl>
706 <dt>
707 (car<a name="index748"> <i>expr</i>) - return the car of a list node
708 <dd>
709 <i>expr</i> - the list node<br>
710 returns - the car of the list node<br>
711
712 <br><dt> (cdr<a name="index749"> <i>expr</i>) - return the cdr of a list node
713 <dd>
714 <i>expr</i> - the list node<br>
715 returns - the cdr of the list node<br>
716
717 <br><dt> (c<i>xx</i>r<a name="index750"> <i>expr</i>) - all c<i>xx</i>r combinations
718 <dd>
719
720 <br>
721 <br><dt> (c<i>xxx</i>r<a name="index751"> <i>expr</i>) - all c<i>xxx</i>r combinations
722 <dd>
723
724 <br>
725 <br><dt> (c<i>xxxx</i>r<a name="index752"> <i>expr</i>) - all c<i>xxxx</i>r combinations
726 <dd>
727
728 <br>
729 <br><dt> (first<a name="index753"> <i>expr</i>) - a synonym for car
730 <dd>
731
732 <br>
733 <br><dt> (second<a name="index754"> <i>expr</i>) - a synonym for cadr
734 <dd>
735
736 <br>
737 <br><dt> (third<a name="index755"> <i>expr</i>) - a synonym for caddr
738 <dd>
739
740 <br>
741 <br><dt> (fourth<a name="index756"> <i>expr</i>) - a synonym for cadddr
742 <dd>
743
744 <br>
745 <br><dt> (rest<a name="index757"> <i>expr</i>) - a synonym for cdr
746 <dd>
747
748 <br>
749 <br><dt> (cons<a name="index758"> <i>expr1</i> <i>expr2</i>) - construct a new list node
750 <dd>
751 <i>expr1</i> - the car of the new list node<br>
752 <i>expr2</i> - the cdr of the new list node<br>
753 returns - the new list node<br>
754
755 <br><dt> (list<a name="index759"> <i>expr</i>...) - create a list of values
756 <dd>
757 <i>expr</i> - expressions to be combined into a list<br>
758 returns - the new list<br>
759
760 <br><dt> (append<a name="index760"> <i>expr</i>...) - append lists
761 <dd>
762 <i>expr</i> - lists whose elements are to be appended<br>
763 returns - the new list<br>
764
765 <br><dt> (reverse<a name="index761"> <i>expr</i>) - reverse a list
766 <dd>
767 <i>expr</i> - the list to reverse<br>
768 returns - a new list in the reverse order<br>
769
770 <br><dt> (last<a name="index762"> <i>list</i>) - return the last list node of a list
771 <dd>
772 <i>list</i> - the list<br>
773 returns - the last list node in the list<br>
774
775 <br><dt> (member<a name="index763"> <i>expr</i> <i>list</i> &amp;key :test :test-not) - find an expression in a list
776 <dd>
777 <i>expr</i> - the expression to find<br>
778 <i>list</i> - the list to search<br>
779 :test - the test function (defaults to eql)<br>
780 :test-not - the test function (sense inverted) <br>
781 returns - the remainder of the list starting with the expression<br>
782
783 <br><dt> (assoc<a name="index764"> <i>expr</i> <i>alist</i> &amp;key :test :test-not) - find an expression in an a-list
784 <dd>
785 <i>expr</i> - the expression to find<br>
786 <i>alist</i> - the association list<br>
787 :test - the test function (defaults to eql)<br>
788 :test-not - the test function (sense inverted) <br>
789 returns - the alist entry or <code>nil</code><br>
790
791 <br><dt> (remove<a name="index765"> <i>expr</i> <i>list</i> &amp;key :test :test-not) - remove elements from a list
792 <dd>
793 <i>expr</i> - the element to remove<br>
794 <i>list</i> - the list<br>
795 :test - the test function (defaults to eql)<br>
796 :test-not - the test function (sense inverted) <br>
797 returns - copy of list with matching expressions removed<br>
798
799 <br><dt> (remove-if<a name="index766"> <i>test</i> <i>list</i>) - remove elements that pass test
800 <dd>
801 <i>test</i> - the test predicate<br>
802 <i>list</i> - the list<br>
803 returns - copy of list with matching elements removed<br>
804
805 <br><dt> (remove-if-not<a name="index767"> <i>test</i> <i>list</i>) - remove elements that fail test
806 <dd>
807 <i>test</i> - the test predicate<br>
808 <i>list</i> - the list<br>
809 returns - copy of list with non-matching elements removed<br>
810
811 <br><dt> (length<a name="index768"> <i>expr</i>) - find the length of a list, vector or string
812 <dd>
813 <i>expr</i> - the list, vector or string<br>
814 returns - the length of the list, vector or string<br>
815
816 <br><dt> (nth<a name="index769"> <i>n</i> <i>list</i>) - return the nth element of a list
817 <dd>
818 <i>n</i> - the number of the element to return (zero origin)<br>
819 <i>list</i> - the list<br>
820 returns - the nth element or <code>nil</code> if the list isn't that long<br>
821
822 <br><dt> (nthcdr<a name="index770"> <i>n</i> <i>list</i>) - return the nth cdr of a list
823 <dd>
824 <i>n</i> - the number of the element to return (zero origin)<br>
825 <i>list</i> - the list<br>
826 returns - the nth cdr or <code>nil</code> if the list isn't that long<br>
827
828 <br><dt> (mapc<a name="index771"> <i>fcn</i> <i>list1</i> <i>list</i>...) - apply function to successive cars
829 <dd>
830 <i>fcn</i> - the function or function name<br>
831 <i>listn</i> - a list for each argument of the function<br>
832 returns - the first list of arguments<br>
833
834 <br><dt> (mapcar<a name="index772"> <i>fcn</i> <i>list1</i> <i>list</i>...) - apply function to successive cars
835 <dd>
836 <i>fcn</i> - the function or function name<br>
837 <i>listn</i> - a list for each argument of the function<br>
838 returns - a list of the values returned<br>
839
840 <br><dt> (mapl<a name="index773"> <i>fcn</i> <i>list1</i> <i>list</i>...) - apply function to successive cdrs
841 <dd>
842 <i>fcn</i> - the function or function name<br>
843 <i>listn</i> - a list for each argument of the function<br>
844 returns - the first list of arguments<br>
845
846 <br><dt> (maplist<a name="index774"> <i>fcn</i> <i>list1</i> <i>list</i>...) - apply function to successive cdrs
847 <dd>
848 <i>fcn</i> - the function or function name<br>
849 <i>listn</i> - a list for each argument of the function<br>
850 returns - a list of the values returned<br>
851
852 <br><dt> (subst<a name="index775"> <i>to</i> <i>from</i> <i>expr</i> &amp;key :test :test-not) - substitute expressions
853 <dd>
854 <i>to</i> - the new expression<br>
855 <i>from</i> - the old expression<br>
856 <i>expr</i> - the expression in which to do the substitutions<br>
857 :test - the test function (defaults to eql)<br>
858 :test-not - the test function (sense inverted) <br>
859 returns - the expression with substitutions<br>
860
861 <br><dt> (sublis<a name="index776"> <i>alist</i> <i>expr</i> &amp;key :test :test-not) - substitute with an a-list
862 <dd>
863 <i>alist</i> - the association list<br>
864 <i>expr</i> - the expression in which to do the substitutions<br>
865 :test - the test function (defaults to eql)<br>
866 :test-not - the test function (sense inverted) <br>
867 returns - the expression with substitutions<br>
868
869 <br><dt>
870 </dl><a name = "120"><h3>Destructive List Functions</h3></a><a name="index777">
871 <dl>
872 <dt>
873 (rplaca<a name="index778"> <i>list</i> <i>expr</i>) - replace the car of a list node
874 <dd>
875 <i>list</i> - the list node<br>
876 <i>expr</i> - the new value for the car of the list node<br>
877 returns - the list node after updating the car<br>
878
879 <br><dt> (rplacd<a name="index779"> <i>list</i> <i>expr</i>) - replace the cdr of a list node
880 <dd>
881 <i>list</i> - the list node<br>
882 <i>expr</i> - the new value for the cdr of the list node<br>
883 returns - the list node after updating the cdr<br>
884
885 <br><dt> (nconc<a name="index780"> <i>list</i>...) - destructively concatenate lists
886 <dd>
887 <i>list</i> - lists to concatenate<br>
888 returns - the result of concatenating the lists<br>
889
890 <br><dt> (delete<a name="index781"> <i>expr</i> &amp;key :test :test-not) - delete elements from a list
891 <dd>
892 <i>expr</i> - the element to delete<br>
893 <i>list</i> - the list<br>
894 :test - the test function (defaults to eql)<br>
895 :test-not - the test function (sense inverted) <br>
896 returns - the list with the matching expressions deleted<br>
897
898 <br><dt> (delete-if<a name="index782"> <i>test</i> <i>list</i>) - delete elements that pass test
899 <dd>
900 <i>test</i> - the test predicate<br>
901 <i>list</i> - the list<br>
902 returns - the list with matching elements deleted<br>
903
904 <br><dt> (delete-if-not<a name="index783"> <i>test</i> <i>list</i>) - delete elements that fail test
905 <dd>
906 <i>test</i> - the test predicate<br>
907 <i>list</i> - the list<br>
908 returns - the list with non-matching elements deleted<br>
909
910 <br><dt> (sort<a name="index784"> <i>list</i> <i>test</i>) - sort a list
911 <dd>
912 <i>list</i> - the list to sort<br>
913 <i>test</i> - the comparison function<br>
914 returns - the sorted list<br>
915
916 <br><dt>
917 </dl><a name = "121"><h3>Predicate Functions</h3></a><a name="index785">
918 <dl>
919 <dt>
920 (atom<a name="index786"> <i>expr</i>) - is this an atom?
921 <dd>
922 <i>expr</i> - the expression to check<br>
923 returns - <code>t</code> if the value is an atom, <code>nil</code> otherwise<br>
924
925 <br><dt> (symbolp<a name="index787"> <i>expr</i>) - is this a symbol?
926 <dd>
927 <i>expr</i> - the expression to check<br>
928 returns - <code>t</code> if the expression is a symbol, <code>nil</code> otherwise<br>
929
930 <br><dt> (numberp<a name="index788"> <i>expr</i>) - is this a number?
931 <dd>
932 <i>expr</i> - the expression to check<br>
933 returns - <code>t</code> if the expression is a number, <code>nil</code> otherwise<br>
934
935 <br><dt> (null<a name="index789"> <i>expr</i>) - is this an empty list?
936 <dd>
937 <i>expr</i> - the list to check<br>
938 returns - <code>t</code> if the list is empty, <code>nil</code> otherwise<br>
939
940 <br><dt> (not<a name="index790"> <i>expr</i>) - is this false?
941 <dd>
942 <i>expr</i> - the expression to check<br>
943 return - <code>t</code> if the value is <code>nil</code>, <code>nil</code> otherwise<br>
944
945 <br><dt> (listp<a name="index791"> <i>expr</i>) - is this a list?
946 <dd>
947 <i>expr</i> - the expression to check<br>
948 returns - <code>t</code> if the value is a cons or <code>nil</code>, <code>nil</code> otherwise<br>
949
950 <br><dt> (endp<a name="index792"> <i>list</i>) - is this the end of a list
951 <dd>
952 <i>list</i> - the list<br>
953 returns - <code>t</code> if the value is <code>nil</code>, <code>nil</code> otherwise<br>
954
955 <br><dt> (consp<a name="index793"> <i>expr</i>) - is this a non-empty list?
956 <dd>
957 <i>expr</i> - the expression to check<br>
958 returns - <code>t</code> if the value is a cons, <code>nil</code> otherwise<br>
959
960 <br><dt> (integerp<a name="index794"> <i>expr</i>) - is this an integer?
961 <dd>
962 <i>expr</i> - the expression to check<br>
963 returns - <code>t</code> if the value is an integer, <code>nil</code> otherwise<br>
964
965 <br><dt> (floatp<a name="index795"> <i>expr</i>) - is this a float?
966 <dd>
967 <i>expr</i> - the expression to check<br>
968 returns - <code>t</code> if the value is a float, <code>nil</code> otherwise<br>
969
970 <br><dt> (stringp<a name="index796"> <i>expr</i>) - is this a string?
971 <dd>
972 <i>expr</i> - the expression to check<br>
973 returns - <code>t</code> if the value is a string, <code>nil</code> otherwise<br>
974
975 <br><dt> (characterp<a name="index797"> <i>expr</i>) - is this a character?
976 <dd>
977 <i>expr</i> - the expression to check<br>
978 returns - <code>t</code> if the value is a character, <code>nil</code> otherwise<br>
979
980 <br><dt> (arrayp<a name="index798"> <i>expr</i>) - is this an array?
981 <dd>
982 <i>expr</i> - the expression to check<br>
983 returns - <code>t</code> if the value is an array, <code>nil</code> otherwise<br>
984
985 <br><dt> (streamp<a name="index799"> <i>expr</i>) - is this a stream?
986 <dd>
987 <i>expr</i> - the expression to check<br>
988 returns - <code>t</code> if the value is a stream, <code>nil</code> otherwise<br>
989
990 <br><dt> (objectp<a name="index800"> <i>expr</i>) - is this an object?
991 <dd>
992 <i>expr</i> - the expression to check<br>
993 returns - <code>t</code> if the value is an object, <code>nil</code> otherwise<br>
994
995 <br><dt> (boundp<a name="index801"> <i>sym</i>) - is a value bound to this symbol?
996 <dd>
997 <i>sym</i> - the symbol<br>
998 returns - <code>t</code> if a value is bound to the symbol, <code>nil</code> otherwise<br>
999
1000 <br><dt> (fboundp<a name="index802"> <i>sym</i>) - is a functional value bound to this symbol?
1001 <dd>
1002 <i>sym</i> - the symbol<br>
1003 returns - <code>t</code> if a functional value is bound to the symbol,<br>
1004 <code>nil</code> otherwise
1005
1006 <br>
1007 <br><dt> (minusp<a name="index803"> <i>expr</i>) - is this number negative?
1008 <dd>
1009 <i>expr</i> - the number to test<br>
1010 returns - <code>t</code> if the number is negative, <code>nil</code> otherwise<br>
1011
1012 <br><dt> (zerop<a name="index804"> <i>expr</i>) - is this number zero?
1013 <dd>
1014 <i>expr</i> - the number to test<br>
1015 returns - <code>t</code> if the number is zero, <code>nil</code> otherwise<br>
1016
1017 <br><dt> (plusp<a name="index805"> <i>expr</i>) - is this number positive?
1018 <dd>
1019 <i>expr</i> - the number to test<br>
1020 returns - <code>t</code> if the number is positive, <code>nil</code> otherwise<br>
1021
1022 <br><dt> (evenp<a name="index806"> <i>expr</i>) - is this integer even?
1023 <dd>
1024 <i>expr</i> - the integer to test<br>
1025 returns - <code>t</code> if the integer is even, <code>nil</code> otherwise<br>
1026
1027 <br><dt> (oddp<a name="index807"> <i>expr</i>) - is this integer odd?
1028 <dd>
1029 <i>expr</i> - the integer to test<br>
1030 returns - <code>t</code> if the integer is odd, <code>nil</code> otherwise<br>
1031
1032 <br><dt> (eq<a name="index808"> <i>expr1</i> <i>expr2</i>) - are the expressions identical?
1033 <dd>
1034 <i>expr1</i> - the first expression<br>
1035 <i>expr2</i> - the second expression<br>
1036 returns - <code>t</code> if they are equal, <code>nil</code> otherwise<br>
1037
1038 <br><dt>(eql<a name="index809"> <i>expr1</i> <i>expr2</i>) - are the expressions
1039 identical? (works with all numbers)
1040 <dd>
1041 <i>expr1</i> - the first expression<br>
1042 <i>expr2</i> - the second expression<br>
1043 returns - <code>t</code> if they are equal, <code>nil</code> otherwise<br>
1044
1045 <br><dt> (equal<a name="index810"> <i>expr1</i> <i>expr2</i>) - are the expressions equal?
1046 <dd>
1047 <i>expr1</i> - the first expression<br>
1048 <i>expr2</i> - the second expression<br>
1049 returns - <code>t</code> if they are equal, <code>nil</code> otherwise<br>
1050
1051 <br><dt>
1052 </dl><a name = "122"><h3>Control Constructs</h3></a><a name="index811">
1053 <dl>
1054 <dt>
1055 (cond<a name="index812"> <i>pair</i>...) - evaluate conditionally
1056 <dd>
1057 <i>pair</i> - pair consisting of:<br>
1058 <dl><dd>
1059 (<i>pred</i> <i>expr</i>...)
1060 </dl>
1061 where:
1062 <dl><dd>
1063 <i>pred</i> - is a predicate expression<br>
1064 <i>expr</i> - evaluated if the predicate
1065 is not <code>nil</code>
1066 </dl>
1067 returns - the value of the first expression whose predicate is not
1068 <code>nil</code>
1069
1070 <br>
1071 <br><dt> (and<a name="index813"> <i>expr</i>...) - the logical and of a list of expressions
1072 <dd>
1073 <i>expr</i> - the expressions to be anded<br>
1074 returns - <code>nil</code> if any expression evaluates to <code>nil</code>,
1075 otherwise the value of the last expression
1076 (evaluation of expressions stops after the first
1077 expression that evaluates to <code>nil</code>)
1078
1079 <br>
1080 <br><dt> (or<a name="index814"> <i>expr</i>...) - the logical or of a list of expressions
1081 <dd>
1082 <i>expr</i> - the expressions to be ored<br>
1083 returns - <code>nil</code> if all expressions evaluate to <code>nil</code>,
1084 otherwise the value of the first non-<code>nil</code> expression
1085 (evaluation of expressions stops after the first
1086 expression that does not evaluate to <code>nil</code>)
1087
1088 <br>
1089 <br><dt> (if<a name="index815"> <i>texpr</i> <i>expr1</i> [<i>expr2</i>]) - evaluate expressions conditionally
1090 <dd>
1091 <i>texpr</i> - the test expression<br>
1092 <i>expr1</i> - the expression to be evaluated if texpr is non-<code>nil</code><br>
1093 <i>expr2</i> - the expression to be evaluated if texpr is <code>nil</code><br>
1094 returns - the value of the selected expression<br>
1095
1096 <br><dt> (when<a name="index816"> <i>texpr</i> <i>expr</i>...) - evaluate only when a condition is true
1097 <dd>
1098 <i>texpr</i> - the test expression<br>
1099 <i>expr</i> - the expression(s) to be evaluated if texpr is non-<code>nil</code><br>
1100 returns - the value of the last expression or <code>nil</code>
1101
1102 <br>
1103 <br><dt> (unless<a name="index817"> <i>texpr</i> <i>expr</i>...) - evaluate only when a condition is false
1104 <dd>
1105 <i>texpr</i> - the test expression<br>
1106 <i>expr</i> - the expression(s) to be evaluated if texpr is <code>nil</code><br>
1107 returns - the value of the last expression or <code>nil</code><br>
1108
1109 <br><dt> (case<a name="index818"> <i>expr</i> <i>case</i>...) - select by case
1110 <dd>
1111 <i>expr</i> - the selection expression<br>
1112 <i>case</i> - pair consisting of:<br>
1113 <dl><dd>
1114 (<i>value</i> <i>expr</i>...)
1115 </dl>
1116 where:
1117 <dl><dd>
1118 <i>value</i> - is a single expression or a list of
1119 expressions (unevaluated)<br>
1120 <i>expr</i> - are expressions to execute if the
1121 case matches
1122 </dl>
1123 returns - the value of the last expression of the matching case<br>
1124
1125 <br><dt>
1126
1127 (let<a name="index819"> (<i>binding</i>...) <i>expr</i>...) - create local bindings<br>
1128 (let*<a name="index820"> (<i>binding</i>...) <i>expr</i>...) - let with sequential binding
1129
1130 <dd>
1131 <i>binding</i> - the variable bindings each of which is either:<br>
1132 <dl><dd>
1133 1) a symbol (which is initialized to <code>nil</code>)<br>
1134 2) a list whose car is a symbol and whose cadr
1135 is an initialization expression
1136 </dl>
1137 <i>expr</i> - the expressions to be evaluated<br>
1138 returns - the value of the last expression<br>
1139
1140 <br><dt>
1141
1142 (flet<a name="index821"> (<i>binding</i>...) <i>expr</i>...) - create local functions<br>
1143 (labels<a name="index822"> (<i>binding</i>...) <i>expr</i>...) - flet with recursive functions<br>
1144 (macrolet<a name="index823"> (<i>binding</i>...) <i>expr</i>...) - create local macros
1145
1146 <dd>
1147 <i>binding</i> - the function bindings each of which is:<br>
1148 <dl><dd>
1149 (<i>sym</i> <i>fargs</i> <i>expr</i>...)
1150 </dl>
1151 where:
1152 <dl><dd>
1153 <i>sym</i> - the function/macro name<br>
1154 <i>fargs</i> - formal argument list (lambda list)<br>
1155 <i>expr</i> - expressions constituting the body of
1156 the function/macro
1157 </dl>
1158 <i>expr</i> - the expressions to be evaluated<br>
1159 returns - the value of the last expression
1160
1161 <br>
1162 <br><dt> (catch<a name="index824"> <i>sym</i> <i>expr</i>...) - evaluate expressions and catch throws
1163 <dd>
1164 <i>sym</i> - the catch tag<br>
1165 <i>expr</i> - expressions to evaluate<br>
1166 returns - the value of the last expression the throw expression<br>
1167
1168 <br><dt> (throw<a name="index825"> <i>sym</i> [<i>expr</i>]) - throw to a catch
1169 <dd>
1170 <i>sym</i> - the catch tag<br>
1171 <i>expr</i> - the value for the catch to return (defaults to <code>nil</code>)<br>
1172 returns - never returns<br>
1173
1174 <br><dt> (unwind-protect<a name="index826"> <i>expr</i> <i>cexpr</i>...) - protect evaluation of an expression
1175 <dd>
1176 <i>expr</i> - the expression to protect<br>
1177 <i>cexpr</i> - the cleanup expressions<br>
1178 returns - the value of the expression<br>
1179 Note: unwind-protect guarantees to execute the cleanup expressions
1180 even if a non-local exit terminates the evaluation of the
1181 protected expression
1182
1183 <br>
1184 <br><dt>
1185 </dl>
1186 <p>
1187 <a name = "123"><h3>Looping Constructs</h3></a><a name="index827">
1188 <dl>
1189 <dt>
1190 (loop<a name="index828"> <i>expr</i>...) - basic looping form
1191 <dd>
1192 <i>expr</i> - the body of the loop<br>
1193 returns - never returns (must use non-local exit)<br>
1194
1195 <br><dt>
1196
1197 (do<a name="index829"> (<i>binding</i>...) (<i>texpr</i> <i>rexpr</i>...) <i>expr</i>...)<br>
1198 (do*<a name="index830"> (<i>binding</i>...) (<i>texpr</i> <i>rexpr</i>...) <i>expr</i>...)
1199
1200 <dd>
1201 <i>binding</i> - the variable bindings each of which is either:<br>
1202 <dl><dd>
1203 1) a symbol (which is initialized to <code>nil</code>)<br>
1204 2) a list of the form: (<i>sym</i> <i>init</i> [<i>step</i>])
1205 where:
1206 <dl><dd>
1207 <i>sym</i> - is the symbol to bind<br>
1208 <i>init</i> - is the initial value of the symbol<br>
1209 <i>step</i> - is a step expression<br>
1210 </dl>
1211 </dl>
1212 <i>texpr</i> - the termination test expression<br>
1213 <i>rexpr</i> - result expressions (the default is <code>nil</code>)<br>
1214 <i>expr</i> - the body of the loop (treated like an implicit prog)<br>
1215 returns - the value of the last result expression<br>
1216
1217 <br><dt> (dolist<a name="index831"> (<i>sym</i> <i>expr</i> [<i>rexpr</i>]) <i>expr</i>...) - loop through a list
1218 <dd>
1219 <i>sym</i> - the symbol to bind to each list element<br>
1220 <i>expr</i> - the list expression<br>
1221 <i>rexpr</i> - the result expression (the default is <code>nil</code>)<br>
1222 <i>expr</i> - the body of the loop (treated like an implicit prog)<br>
1223
1224 <br><dt> (dotimes<a name="index832"> (<i>sym</i> <i>expr</i> [<i>rexpr</i>]) <i>expr</i>...) - loop from zero to n-1
1225 <dd>
1226 <i>sym</i> - the symbol to bind to each value from 0 to n-1<br>
1227 <i>expr</i> - the number of times to loop<br>
1228 <i>rexpr</i> - the result expression (the default is <code>nil</code>)<br>
1229 <i>expr</i> - the body of the loop (treated like an implicit prog)<br>
1230
1231 <br><dt>
1232 </dl><a name = "124"><h3>The Program Feature</h3></a><a name="index833">
1233 <dl>
1234 <dt>
1235
1236 (prog<a name="index834"> (<i>binding</i>...) <i>expr</i>...) - the program feature<br>
1237 (prog*<a name="index835"> (<i>binding</i>...) <i>expr</i>...) - prog with sequential binding
1238
1239 <dd>
1240 <i>binding</i> - the variable bindings each of which is either:<br>
1241 <dl><dd>
1242 1) a symbol (which is initialized to <code>nil</code>)<br>
1243 2) a list whose car is a symbol and whose cadr
1244 is an initialization expression
1245 </dl>
1246 <i>expr</i> - expressions to evaluate or tags (symbols)<br>
1247 returns - <code>nil</code> or the argument passed to the return function<br>
1248
1249 <br><dt> (block<a name="index836"> <i>name</i> <i>expr</i>...) - named block
1250 <dd>
1251 <i>name</i> - the block name (symbol)<br>
1252 <i>expr</i> - the block body<br>
1253 returns - the value of the last expression<br>
1254
1255 <br><dt> (return<a name="index837"> [<i>expr</i>]) - cause a prog construct to return a value
1256 <dd>
1257 <i>expr</i> - the value (defaults to <code>nil</code>)<br>
1258 returns - never returns<br>
1259
1260 <br><dt> (return-from<a name="index838"> <i>name</i> [<i>value</i>]) - return from a named block
1261 <dd>
1262 <i>name</i> - the block name (symbol)<br>
1263 <i>value</i> - the value to return (defaults to <code>nil</code>)<br>
1264 returns - never returns<br>
1265
1266 <br><dt> (tagbody<a name="index839"> <i>expr</i>...) - block with labels
1267 <dd>
1268 <i>expr</i> - expression(s) to evaluate or tags (symbols)<br>
1269 returns - <code>nil</code><br>
1270
1271 <br><dt> (go<a name="index840"> <i>sym</i>) - go to a tag within a tagbody or prog
1272 <dd>
1273 <i>sym</i> - the tag (quoted)<br>
1274 returns - never returns<br>
1275
1276 <br><dt> (progv<a name="index841"> <i>slist</i> <i>vlist</i> <i>expr</i>...) - dynamically bind symbols
1277 <dd>
1278 <i>slist</i> - list of symbols<br>
1279 <i>vlist</i> - list of values to bind to the symbols<br>
1280 <i>expr</i> - expression(s) to evaluate<br>
1281 returns - the value of the last expression<br>
1282
1283 <br><dt> (prog1<a name="index842"> <i>expr1</i> <i>expr</i>...) - execute expressions sequentially
1284 <dd>
1285 <i>expr1</i> - the first expression to evaluate<br>
1286 <i>expr</i> - the remaining expressions to evaluate<br>
1287 returns - the value of the first expression<br>
1288
1289 <br><dt> (prog2<a name="index843"> <i>expr1</i> <i>expr2</i> <i>expr</i>...) - execute expressions sequentially
1290 <dd>
1291 <i>expr1</i> - the first expression to evaluate<br>
1292 <i>expr2</i> - the second expression to evaluate<br>
1293 <i>expr</i> - the remaining expressions to evaluate<br>
1294 returns - the value of the second expression<br>
1295
1296 <br><dt> (progn<a name="index844"> <i>expr</i>...) - execute expressions sequentially
1297 <dd>
1298 <i>expr</i> - the expressions to evaluate<br>
1299 returns - the value of the last expression (or <code>nil</code>)<br>
1300
1301 <br><dt>
1302 </dl><a name = "125"><h3>Debugging and Error Handling</h3></a><a name="index845"><a name="index846">
1303 <dl>
1304 <dt>
1305 (trace<a name="index847"> <i>sym</i>) - add a function to the trace list
1306 <dd>
1307 <i>sym</i> - the function to add (quoted)<br>
1308 returns - the trace list<br>
1309
1310 <br><dt> (untrace<a name="index848"> <i>sym</i>) - remove a function from the trace list
1311 <dd>
1312 <i>sym</i> - the function to remove (quoted)<br>
1313 returns - the trace list<br>
1314
1315 <br><dt> (error<a name="index849"> <i>emsg</i> [<i>arg</i>]) - signal a non-correctable error
1316 <dd>
1317 <i>emsg</i> - the error message string<br>
1318 <i>arg</i> - the argument expression (printed after the message)<br>
1319 returns - never returns<br>
1320
1321 <br><dt> (cerror<a name="index850"> <i>cmsg</i> <i>emsg</i> [<i>arg</i>]) - signal a correctable error
1322 <dd>
1323 <i>cmsg</i> - the continue message string<br>
1324 <i>emsg</i> - the error message string<br>
1325 <i>arg</i> - the argument expression (printed after the message)<br>
1326 returns - <code>nil</code> when continued from the break loop<br>
1327
1328 <br><dt> (break<a name="index851"> [<i>bmsg</i> [<i>arg</i>]]) - enter a break loop
1329 <dd>
1330 <i>bmsg</i> - the break message string (defaults to <code>**break**</code>)<br>
1331 <i>arg</i> - the argument expression (printed after the message)<br>
1332 returns - <code>nil</code> when continued from the break loop<br>
1333
1334 <br><dt> (clean-up<a name="index852">) - clean-up after an error
1335 <dd>
1336 returns - never returns<br>
1337
1338 <br><dt> (top-level<a name="index853">) - clean-up after an error and return to the top level
1339 <dd>
1340 returns - never returns<br>
1341
1342 <br><dt> (continue<a name="index854">) - continue from a correctable error
1343 <dd>
1344 returns - never returns<br>
1345
1346 <br><dt> (errset<a name="index855"> <i>expr</i> [<i>pflag</i>]) - trap errors
1347 <dd>
1348 <i>expr</i> - the expression to execute<br>
1349 <i>pflag</i> - flag to control printing of the error message<br>
1350 returns - the value of the last expression consed with <code>nil</code><br>
1351 or <code>nil</code> on error
1352
1353 <br>
1354 <br><dt> (baktrace<a name="index856"><a name="index857"><a name="index858"> [<i>n</i>]) - print n levels of trace back information
1355 <dd>
1356 <i>n</i> - the number of levels (defaults to all levels)<br>
1357 returns - <code>nil</code><br>
1358
1359 <br><dt> (evalhook<a name="index859"> <i>expr</i> <i>ehook</i> <i>ahook</i> [<i>env</i>]) - evaluate with hooks
1360 <dd>
1361 <i>expr</i> - the expression to evaluate<br>
1362 <i>ehook</i> - the value for <code>*evalhook*</code><br>
1363 <i>ahook</i> - the value for <code>*applyhook*</code><br>
1364 <i>env</i> - the environment (default is <code>nil</code>)<br>
1365 returns - the result of evaluating the expression<br>
1366
1367 <br><dt> (profile<a name="index860"> <i>flag</i>) <a href = "foot.html#foot3">(Footnote 3)</a> - turn profiling on or off.
1368 <dd>
1369 <i>flag</i> - <code>nil</code> turns profiling off, otherwise on<br>
1370 returns - the previous state of profiling.<br>
1371
1372 <br><dt>
1373 </dl><a name = "126"><h3>Arithmetic Functions</h3></a><a name="index861">
1374 <dl>
1375 <dt>
1376 (truncate<a name="index862"> <i>expr</i>) - truncates a floating point number to an integer
1377 <dd>
1378 <i>expr</i> - the number<br>
1379 returns - the result of truncating the number<br>
1380
1381 <br><dt> (float<a name="index863"> <i>expr</i>) - converts an integer to a floating point number
1382 <dd>
1383 <i>expr</i> - the number<br>
1384 returns - the result of floating the integer<br>
1385
1386 <br><dt> (+<a name="index864"> <i>expr</i>...) - add a list of numbers
1387 <dd>
1388 <i>expr</i> - the numbers<br>
1389 returns - the result of the addition<br>
1390
1391 <br><dt> (-<a name="index865"> <i>expr</i>...) - subtract a list of numbers or negate a single number
1392 <dd>
1393 <i>expr</i> - the numbers<br>
1394 returns - the result of the subtraction<br>
1395
1396 <br><dt> (*<a name="index866"> <i>expr</i>...) - multiply a list of numbers
1397 <dd>
1398 <i>expr</i> - the numbers<br>
1399 returns - the result of the multiplication<br>
1400
1401 <br><dt> (/<a name="index867"> <i>expr</i>...) - divide a list of numbers
1402 <dd>
1403 <i>expr</i> - the numbers<br>
1404 returns - the result of the division<br>
1405
1406 <br><dt> (1+<a name="index868"> <i>expr</i>) - add one to a number
1407 <dd>
1408 <i>expr</i> - the number<br>
1409 returns - the number plus one<br>
1410
1411 <br><dt> (1-<a name="index869"> <i>expr</i>) - subtract one from a number
1412 <dd>
1413 <i>expr</i> - the number<br>
1414 returns - the number minus one<br>
1415
1416 <br><dt> (rem<a name="index870"><a name="index871"><a name="index872"> <i>expr</i>...) - remainder of a list of numbers
1417 <dd>
1418 <i>expr</i> - the numbers<br>
1419 returns - the result of the remainder operation<br>
1420
1421 <br><dt> (min<a name="index873"><a name="index874"> <i>expr</i>...) - the smallest of a list of numbers
1422 <dd>
1423 <i>expr</i> - the expressions to be checked<br>
1424 returns - the smallest number in the list<br>
1425
1426 <br><dt> (max<a name="index875"><a name="index876"> <i>expr</i>...) - the largest of a list of numbers
1427 <dd>
1428 <i>expr</i> - the expressions to be checked<br>
1429 returns - the largest number in the list<br>
1430
1431 <br><dt> (abs<a name="index877"> <i>expr</i>) - the absolute value of a number
1432 <dd>
1433 <i>expr</i> - the number<br>
1434 returns - the absolute value of the number<br>
1435
1436 <br><dt> (gcd<a name="index878"> <i>n1</i> <i>n2</i>...) - compute the greatest common divisor
1437 <dd>
1438 <i>n1</i> - the first number (integer)<br>
1439 <i>n2</i> - the second number(s) (integer)<br>
1440 returns - the greatest common divisor<br>
1441
1442 <br><dt> (random<a name="index879"> <i>n</i>) - compute a random number between 1 and n-1
1443 <dd>
1444 <i>n</i> - the upper bound (integer)<br>
1445 returns - a random number<br>
1446
1447 <br><dt> (sin<a name="index880"> <i>expr</i>) - compute the sine of a number
1448 <dd>
1449 <i>expr</i> - the floating point number<br>
1450 returns - the sine of the number<br>
1451
1452 <br><dt> (cos<a name="index881"> <i>expr</i>) - compute the cosine of a number
1453 <dd>
1454 <i>expr</i> - the floating point number<br>
1455 returns - the cosine of the number<br>
1456
1457 <br><dt> (tan<a name="index882"> <i>expr</i>) - compute the tangent of a number
1458 <dd>
1459 <i>expr</i> - the floating point number<br>
1460 returns - the tangent of the number<br>
1461
1462 <br><dt> (expt<a name="index883"> <i>x-expr</i> <i>y-expr</i>) - compute x to the y power
1463 <dd>
1464 <i>x-expr</i> - the floating point number<br>
1465 <i>y-expr</i> - the floating point exponent<br>
1466 returns - x to the y power<br>
1467
1468 <br><dt> (exp<a name="index884"> <i>x-expr</i>) - compute e to the x power
1469 <dd>
1470 <i>x-expr</i> - the floating point number<br>
1471 returns - e to the x power<br>
1472
1473 <br><dt> (sqrt<a name="index885"> <i>expr</i>) - compute the square root of a number
1474 <dd>
1475 <i>expr</i> - the floating point number<br>
1476 returns - the square root of the number<br>
1477
1478 <br><dt>
1479
1480 (&lt<a name="index886"> <i>n1</i> <i>n2</i>...) - test for less than<br>
1481 (&lt=<a name="index887"> <i>n1</i> <i>n2</i>...) - test for less than or equal to<br>
1482 (=<a name="index888"> <i>n1</i> <i>n2</i>...) - test for equal to<br>
1483 (/=<a name="index889"> <i>n1</i> <i>n2</i>...) - test for not equal to<br>
1484 (&gt=<a name="index890"> <i>n1</i> <i>n2</i>...) - test for greater than or equal to<br>
1485 (&gt<a name="index891"> <i>n1</i> <i>n2</i>...) - test for greater than
1486
1487 <dd>
1488 <i>n1</i> - the first number to compare<br>
1489 <i>n2</i> - the second number to compare<br>
1490 returns - <code>t</code> if the results of comparing <i>n1</i> with <i>n2</i>,
1491 <i>n2</i> with <i>n3</i>, etc., are all true.<br>
1492
1493 <br><dt>
1494 </dl><a name = "127"><h3>Bitwise Logical Functions</h3></a><a name="index892">
1495 <dl>
1496 <dt>
1497 (logand<a name="index893"> <i>expr</i>...) - the bitwise and of a list of numbers
1498 <dd>
1499 <i>expr</i> - the numbers<br>
1500 returns - the result of the and operation<br>
1501
1502 <br><dt> (logior<a name="index894"> <i>expr</i>...) - the bitwise inclusive or of a list of numbers
1503 <dd>
1504 <i>expr</i> - the numbers<br>
1505 returns - the result of the inclusive or operation<br>
1506
1507 <br><dt> (logxor<a name="index895"> <i>expr</i>...) - the bitwise exclusive or of a list of numbers
1508 <dd>
1509 <i>expr</i> - the numbers<br>
1510 returns - the result of the exclusive or operation<br>
1511
1512 <br><dt> (lognot<a name="index896"> <i>expr</i>) - the bitwise not of a number
1513 <dd>
1514 <i>expr</i> - the number<br>
1515 returns - the bitwise inversion of number<br>
1516
1517 <br><dt>
1518 </dl><a name = "128"><h3>String Functions</h3></a><a name="index897">
1519 <dl>
1520 <dt>
1521 (string<a name="index898"> <i>expr</i>) - make a string from an integer ascii value
1522 <dd>
1523 <i>expr</i> - the integer<br>
1524 returns - a one character string<br>
1525
1526 <br><dt> (string-search<a name="index899"> <i>pat</i> <i>str</i> &amp;key :start :end) <a href = "foot.html#foot4">(Footnote 4)</a> - search for pattern in string
1527 <dd>
1528 <i>pat</i> - a string to search for<br>
1529 <i>str</i> - the string to be searched<br>
1530 :start - the starting offset in str<br>
1531 :end - the ending offset + 1<br>
1532 returns - index of pat in str or NIL if not found<br>
1533
1534 <br><dt> (string-trim<a name="index900"> <i>bag</i> <i>str</i>) - trim both ends of a string
1535 <dd>
1536 <i>bag</i> - a string containing characters to trim<br>
1537 <i>str</i> - the string to trim<br>
1538 returns - a trimed copy of the string<br>
1539
1540 <br><dt> (string-left-trim<a name="index901"> <i>bag</i> <i>str</i>) - trim the left end of a string
1541 <dd>
1542 <i>bag</i> - a string containing characters to trim<br>
1543 <i>str</i> - the string to trim<br>
1544 returns - a trimed copy of the string<br>
1545
1546 <br><dt> (string-right-trim<a name="index902"> <i>bag</i> <i>str</i>) - trim the right end of a string
1547 <dd>
1548 <i>bag</i> - a string containing characters to trim<br>
1549 <i>str</i> - the string to trim<br>
1550 returns - a trimed copy of the string<br>
1551
1552 <br><dt> (string-upcase<a name="index903"> <i>str</i> &amp;key :start :end) - convert to uppercase
1553 <dd>
1554 <i>str</i> - the string<br>
1555 :start - the starting offset<br>
1556 :end - the ending offset + 1<br>
1557 returns - a converted copy of the string<br>
1558
1559 <br><dt> (string-downcase<a name="index904"> <i>str</i> &amp;key :start :end) - convert to lowercase
1560 <dd>
1561 <i>str</i> - the string<br>
1562 :start - the starting offset<br>
1563 :end - the ending offset + 1<br>
1564 returns - a converted copy of the string<br>
1565
1566 <br><dt> (nstring-upcase<a name="index905"> <i>str</i> &amp;key :start :end) - convert to uppercase
1567 <dd>
1568 <i>str</i> - the string<br>
1569 :start - the starting offset<br>
1570 :end - the ending offset + 1<br>
1571 returns - the converted string (not a copy)<br>
1572
1573 <br><dt> (nstring-downcase<a name="index906"> <i>str</i> &amp;key :start :end) - convert to lowercase
1574 <dd>
1575 <i>str</i> - the string<br>
1576 :start - the starting offset<br>
1577 :end - the ending offset + 1<br>
1578 returns - the converted string (not a copy)<br>
1579
1580 <br><dt> (strcat<a name="index907"><a name="index908"> <i>expr</i>...) - concatenate strings
1581 <dd>
1582 <i>expr</i> - the strings to concatenate<br>
1583 returns - the result of concatenating the strings<br>
1584
1585 <br><dt> (subseq<a name="index909"> <i>string</i> <i>start</i> [<i>end</i>]) - extract a substring
1586 <dd>
1587 <i>string</i> - the string<br>
1588 <i>start</i> - the starting position (zero origin)<br>
1589 <i>end</i> - the ending position + 1 (defaults to end)<br>
1590 returns - substring between <i>start</i> and <i>end</i><br>
1591
1592 <br><dt>
1593
1594 (string&lt<a name="index910"> <i>str1</i> <i>str2</i> &amp;key :start1 :end1 :start2 :end2)<br>
1595 (string&lt=<a name="index911"> <i>str1</i> <i>str2</i> &amp;key :start1 :end1 :start2 :end2)<br>
1596 (string=<a name="index912"> <i>str1</i> <i>str2</i> &amp;key :start1 :end1 :start2 :end2)<br>
1597 (string/=<a name="index913"> <i>str1</i> <i>str2</i> &amp;key :start1 :end1 :start2 :end2)<br>
1598 (string&gt=<a name="index914"> <i>str1</i> <i>str2</i> &amp;key :start1 :end1 :start2 :end2)<br>
1599 (string&gt<a name="index915"> <i>str1</i> <i>str2</i> &amp;key :start1 :end1 :start2 :end2)
1600
1601 <dd>
1602 <i>str1</i> - the first string to compare<br>
1603 <i>str2</i> - the second string to compare<br>
1604 :start1 - first substring starting offset<br>
1605 :end1 - first substring ending offset + 1<br>
1606 :start2 - second substring starting offset<br>
1607 :end2 - second substring ending offset + 1<br>
1608 returns - <code>t</code> if predicate is true, <code>nil</code> otherwise<br>
1609 Note: case is significant with these comparison functions.
1610
1611 <br>
1612 <br><dt>
1613
1614 (string-lessp<a name="index916"> <i>str1</i> <i>str2</i> &amp;key :start1 :end1 :start2 :end2)<br>
1615 (string-not-greaterp<a name="index917"> <i>str1</i> <i>str2</i> &amp;key :start1 :end1 :start2 :end2)<br>
1616 (string-equalp<a name="index918"> <i>str1</i> <i>str2</i> &amp;key :start1 :end1 :start2 :end2)<br>
1617 (string-not-equalp<a name="index919"> <i>str1</i> <i>str2</i> &amp;key :start1 :end1 :start2 :end2)<br>
1618 (string-not-lessp<a name="index920"> <i>str1</i> <i>str2</i> &amp;key :start1 :end1 :start2 :end2)<br>
1619 (string-greaterp <i>str1</i> <i>str2</i> &amp;key :start1 :end1 :start2 :end2)
1620
1621 <dd>
1622 <i>str1</i> - the first string to compare<br>
1623 <i>str2</i> - the second string to compare<br>
1624 :start1 - first substring starting offset<br>
1625 :end1 - first substring ending offset + 1<br>
1626 :start2 - second substring starting offset<br>
1627 :end2 - second substring ending offset + 1<br>
1628 returns - <code>t</code> if predicate is true, <code>nil</code> otherwise<br>
1629 Note: case is not significant with these comparison functions.
1630
1631 <br>
1632 <br><dt>
1633 </dl>
1634 <p>
1635 <a name = "129"><h3>Character Functions</h3></a><a name="index921">
1636 <dl>
1637 <dt>
1638 (char<a name="index922"> <i>string</i> <i>index</i>) - extract a character from a string
1639 <dd>
1640 <i>string</i> - the string<br>
1641 <i>index</i> - the string index (zero relative)<br>
1642 returns - the ascii code of the character<br>
1643
1644 <br><dt> (upper-case-p<a name="index923"> <i>chr</i>) - is this an upper case character?
1645 <dd>
1646 <i>chr</i> - the character<br>
1647 returns - <code>t</code> if the character is upper case, <code>nil</code> otherwise<br>
1648
1649 <br><dt> (lower-case-p<a name="index924"> <i>chr</i>) - is this a lower case character?
1650 <dd>
1651 <i>chr</i> - the character<br>
1652 returns - <code>t</code> if the character is lower case, <code>nil</code> otherwise<br>
1653
1654 <br><dt> (both-case-p<a name="index925"> <i>chr</i>) - is this an alphabetic (either case) character?
1655 <dd>
1656 <i>chr</i> - the character<br>
1657 returns - <code>t</code> if the character is alphabetic, <code>nil</code> otherwise<br>
1658
1659 <br><dt> (digit-char-p<a name="index926"> <i>chr</i>) - is this a digit character?
1660 <dd>
1661 <i>chr</i> - the character<br>
1662 returns - the digit weight if character is a digit, <code>nil</code> otherwise<br>
1663
1664 <br><dt> (char-code<a name="index927"> <i>chr</i>) - get the ascii code of a character
1665 <dd>
1666 <i>chr</i> - the character<br>
1667 returns - the ascii character code (integer)<br>
1668
1669 <br><dt> (code-char<a name="index928"> <i>code</i>) - get the character with a specified ascii code
1670 <dd>
1671 <i>code</i> - the ascii code (integer)<br>
1672 returns - the character with that code or <code>nil</code><br>
1673
1674 <br><dt> (char-upcase<a name="index929"> <i>chr</i>) - convert a character to upper case
1675 <dd>
1676 <i>chr</i> - the character<br>
1677 returns - the upper case character<br>
1678
1679 <br><dt> (char-downcase<a name="index930"> <i>chr</i>) - convert a character to lower case
1680 <dd>
1681 <i>chr</i> - the character<br>
1682 returns - the lower case character<br>
1683
1684 <br><dt> (digit-char<a name="index931"> <i>n</i>) - convert a digit weight to a digit
1685 <dd>
1686 <i>n</i> - the digit weight (integer)<br>
1687 returns - the digit character or <code>nil</code><br>
1688
1689 <br><dt> (char-int<a name="index932"> <i>chr</i>) - convert a character to an integer
1690 <dd>
1691 <i>chr</i> - the character<br>
1692 returns - the ascii character code<br>
1693
1694 <br><dt> (int-char<a name="index933"> <i>int</i>) - convert an integer to a character
1695 <dd>
1696 <i>int</i> - the ascii character code<br>
1697 returns - the character with that code<br>
1698
1699 <br><dt>
1700
1701 (char&lt<a name="index934"> <i>chr1</i> <i>chr2</i>...)<br>
1702 (char&lt=<a name="index935"> <i>chr1</i> <i>chr2</i>...)<br>
1703 (char=<a name="index936"> <i>chr1</i> <i>chr2</i>...)<br>
1704 (char/=<a name="index937"> <i>chr1</i> <i>chr2</i>...)<br>
1705 (char&gt=<a name="index938"> <i>chr1</i> <i>chr2</i>...)<br>
1706 (char&gt<a name="index939"> <i>chr1</i> <i>chr2</i>...)
1707
1708 <dd>
1709 <i>chr1</i> - the first character to compare<br>
1710 <i>chr2</i> - the second character(s) to compare<br>
1711 returns - <code>t</code> if predicate is true, <code>nil</code> otherwise<br>
1712 Note: case is significant with these comparison functions.
1713
1714 <br>
1715 <br><dt>
1716
1717 (char-lessp<a name="index940"> <i>chr1</i> <i>chr2</i>...)<br>
1718 (char-not-greaterp<a name="index941"> <i>chr1</i> <i>chr2</i>...)<br>
1719 (char-equalp<a name="index942"> <i>chr1</i> <i>chr2</i>...)<br>
1720 (char-not-equalp<a name="index943"> <i>chr1</i> <i>chr2</i>...)<br>
1721 (char-not-lessp<a name="index944"> <i>chr1</i> <i>chr2</i>...)<br>
1722 (char-greaterp<a name="index945"> <i>chr1</i> <i>chr2</i>...)
1723
1724 <dd>
1725 <i>chr1</i> - the first string to compare<br>
1726 <i>chr2</i> - the second string(s) to compare<br>
1727 returns - <code>t</code> if predicate is true, <code>nil</code> otherwise<br>
1728
1729 <br><dt>
1730 Note: case is not significant with these comparison functions.
1731 </dl>
1732 <p>
1733 <a name = "130"><h3>Input/Output Functions</h3></a><a name="index946">
1734 <dl>
1735 <dt>
1736 (read<a name="index947"> [<i>stream</i> [<i>eof</i> [<i>rflag</i>]]]) - read an expression
1737 <dd>
1738 <i>stream</i> - the input stream (default is standard input)<br>
1739 <i>eof</i> - the value to return on end of file (default is <code>nil</code>)<br>
1740 <i>rflag</i> - recursive read flag (default is <code>nil</code>)<br>
1741 returns - the expression read<br>
1742
1743 <br><dt> (print<a name="index948"> <i>expr</i> [<i>stream</i>]) - print an expression on a new line
1744 <dd>
1745 <i>expr</i> - the expression to be printed<br>
1746 <i>stream</i> - the output stream (default is standard output)<br>
1747 returns - the expression<br>
1748
1749 <br><dt> (prin1<a name="index949"> <i>expr</i> [<i>stream</i>]) - print an expression
1750 <dd>
1751 <i>expr</i> - the expression to be printed<br>
1752 <i>stream</i> - the output stream (default is standard output)<br>
1753 returns - the expression<br>
1754
1755 <br><dt> (princ<a name="index950"> <i>expr</i> [<i>stream</i>]) - print an expression without quoting
1756 <dd>
1757 <i>expr</i> - the expressions to be printed<br>
1758 <i>stream</i> - the output stream (default is standard output)<br>
1759 returns - the expression<br>
1760
1761 <br><dt> (pprint<a name="index951"> <i>expr</i> [<i>stream</i>]) - pretty print an expression
1762 <dd>
1763 <i>expr</i> - the expressions to be printed<br>
1764 <i>stream</i> - the output stream (default is standard output)<br>
1765 returns - the expression<br>
1766
1767 <br><dt> (terpri<a name="index952"> [<i>stream</i>]) - terminate the current print line
1768 <dd>
1769 <i>stream</i> - the output stream (default is standard output)<br>
1770 returns - <code>nil</code><br>
1771
1772 <br><dt> (flatsize<a name="index953"> <i>expr</i>) - length of printed representation using prin1
1773 <dd>
1774 <i>expr</i> - the expression<br>
1775 returns - the length<br>
1776
1777 <br><dt> (flatc<a name="index954"> <i>expr</i>) - length of printed representation using princ
1778 <dd>
1779 <i>expr</i> - the expression<br>
1780 returns - the length<br>
1781
1782 <br><dt>
1783 </dl><a name = "131"><h3>The Format Function</h3></a><a name="index955">
1784 <dl>
1785 <dt>
1786 (format<a name="index956"> <i>stream</i> <i>fmt</i> <i>arg</i>...) - do formated
1787 output
1788 <dd>
1789 <i>stream</i> - the output stream<br>
1790 <i>fmt</i> - the format string<br>
1791 <i>arg</i> - the format arguments<br>
1792 returns - output string if <i>stream</i> is <code>nil</code>, <code>nil</code> otherwise<br>
1793
1794 <br><dt>
1795 </dl>
1796 The format string can contain characters that should be copied
1797 directly to the output and formatting directives. The
1798 formatting directives are:
1799 <blockquote>
1800 ~A - print next argument using princ<br>
1801
1802 ~S - print next argument using prin1<br>
1803
1804 ~% - start a new line<br>
1805
1806 ~~ - print a tilde character<br>
1807
1808 </blockquote>
1809 <p>
1810 <a name = "132"><h3>File I/O Functions</h3></a><a name="index957">
1811 Note that files are ordinarily opened as text. Binary files (such as standard midi files) must be opened with <code>open-binary</code> on non-unix systems.
1812 <dl>
1813 <dt>
1814 (open<a name="index958"> <i>fname</i> &amp;key :direction) - open a file stream
1815 <dd>
1816 <i>fname</i> - the file name string or symbol<br>
1817 :direction - :input or :output (default is :input)<br>
1818 returns - a stream<br>
1819
1820 <br><dt>
1821 (open-binary<a name="index959"><a name="index960"> <i>fname</i> &amp;key :direction) - open a binary file stream
1822 <dd>
1823 <i>fname</i> - the file name string or symbol<br>
1824 :direction - :input or :output (default is :input)<br>
1825 returns - a stream<br>
1826
1827 <br><dt> (close<a name="index961"> <i>stream</i>) - close a file stream
1828 <dd>
1829 <i>stream</i> - the stream<br>
1830 returns - <code>nil</code><br>
1831
1832 <br><dt> (read-char<a name="index962"> [<i>stream</i>]) - read a character from a stream
1833 <dd>
1834 <i>stream</i> - the input stream (default is standard input)<br>
1835 returns - the character<br>
1836
1837 <br><dt> (peek-char<a name="index963"> [<i>flag</i> [<i>stream</i>]]) - peek at the next character
1838 <dd>
1839 <i>flag</i> - flag for skipping white space (default is <code>nil</code>)<br>
1840 <i>stream</i> - the input stream (default is standard input)<br>
1841 returns - the character (integer)<br>
1842
1843 <br><dt> (write-char<a name="index964"> <i>ch</i> [<i>stream</i>]) - write a character to a stream
1844 <dd>
1845 <i>ch</i> - the character to write<br>
1846 <i>stream</i> - the output stream (default is standard output)<br>
1847 returns - the character<br>
1848
1849 <br><dt> (read-int<a name="index965"> [<i>stream</i> [<i>length</i>]]) - read a binary integer from a stream
1850 <dd>
1851 <i>stream</i> - the input stream (default is standard input)<br>
1852 <i>length</i> - the length of the integer in bytes (default is 4)<br>
1853 returns - the integer<br>
1854 Note: Integers are assumed to be big-endian (high-order byte first) and
1855 signed, regardless of the platform. To read little-endian format, use a
1856 negative number for the length, e.g. -4 indicates a 4-bytes, low-order
1857 byte first. The file should be opened in binary mode.<br>
1858
1859 <br><dt> (write-int<a name="index966"> <i>ch</i> [<i>stream</i> [<i>length</i>]]) - write a binary integer to a stream
1860 <dd>
1861 <i>ch</i> - the character to write<br>
1862 <i>stream</i> - the output stream (default is standard output)<br>
1863 <i>length</i> - the length of the integer in bytes (default is 4)<br>
1864 returns - the integer<br>
1865 Note: Integers are assumed to be big-endian (high-order byte first) and
1866 signed, regardless of the platform. To write in little-endian format, use a
1867 negative number for the length, e.g. -4 indicates a 4-bytes, low-order
1868 byte first. The file should be opened in binary mode.<br>
1869
1870 <br><dt> (read-float<a name="index967"> [<i>stream</i> [<i>length</i>]]) - read a binary floating-point number from a stream
1871 <dd>
1872 <i>stream</i> - the input stream (default is standard input)<br>
1873 <i>length</i> - the length of the float in bytes (default is 4, legal values are -4, -8, 4, and 8)<br>
1874 returns - the integer<br>
1875 Note: Floats are assumed to be big-endian (high-order byte first) and
1876 signed, regardless of the platform. To read little-endian format, use a
1877 negative number for the length, e.g. -4 indicates a 4-bytes, low-order
1878 byte first. The file should be opened in binary mode.<br>
1879
1880 <br><dt> (write-float<a name="index968"> <i>ch</i> [<i>stream</i> [<i>length</i>]]) - write a binary floating-point number to a stream
1881 <dd>
1882 <i>ch</i> - the character to write<br>
1883 <i>stream</i> - the output stream (default is standard output)<br>
1884 <i>length</i> - the length of the float in bytes (default is 4, legal values are -4, -8, 4, and 8)<br>
1885 returns - the integer<br>
1886 Note: Floats are assumed to be big-endian (high-order byte first) and
1887 signed, regardless of the platform. To write in little-endian format, use a
1888 negative number for the length, e.g. -4 indicates a 4-bytes, low-order
1889 byte first. The file should be opened in binary mode.<br>
1890
1891 <br><dt> (read-line<a name="index969"> [<i>stream</i>]) - read a line from a stream
1892 <dd>
1893 <i>stream</i> - the input stream (default is standard input)<br>
1894 returns - the string<br>
1895
1896 <br><dt> (read-byte<a name="index970"> [<i>stream</i>]) - read a byte from a stream
1897 <dd>
1898 <i>stream</i> - the input stream (default is standard input)<br>
1899 returns - the byte (integer)<br>
1900
1901 <br><dt> (write-byte<a name="index971"> <i>byte</i> [<i>stream</i>]) - write a byte to a stream
1902 <dd>
1903 <i>byte</i> - the byte to write (integer)<br>
1904 <i>stream</i> - the output stream (default is standard output)<br>
1905 returns - the byte (integer)<br>
1906
1907 <br><dt>
1908 </dl><a name = "133"><h3>String Stream Functions</h3></a><a name="index972">
1909 These functions operate on unnamed streams. An unnamed output
1910 stream collects characters sent to it when it is used as the
1911 destination of any output function. The functions
1912 <code>get-output-stream-string</code> and string or a list of characters.
1913 <p>
1914 An unnamed input stream is setup with the
1915 <code>make-string-input-stream</code> function and returns each character of the string when
1916 it is used as the source of any input function.
1917 <p>
1918 <dl>
1919 <dt>
1920 <br><dt>
1921 (make-string-input-stream<a name="index973"> <i>str</i> [<i>start</i> [<i>end</i>]])
1922 <dd>
1923 <i>str</i> - the string<br>
1924 <i>start</i> - the starting offset<br>
1925 <i>end</i> - the ending offset + 1<br>
1926 returns - an unnamed stream that reads from the string<br>
1927
1928 <br><dt> (make-string-output-stream)<a name="index974">
1929 <dd>
1930 returns - an unnamed output stream<br>
1931
1932 <br><dt> (get-output-stream-string<a name="index975"> <i>stream</i>)
1933 <dd>
1934 <i>stream</i> - the output stream<br>
1935 returns - the output so far as a string<br>
1936
1937 Note: the output stream is emptied by this function
1938 <br>
1939 <br><dt> (get-output-stream-list<a name="index976"> <i>stream</i>)
1940 <dd>
1941 <i>stream</i> - the output stream<br>
1942 returns - the output so far as a list<br>
1943
1944 Note: the output stream is emptied by this function
1945 <br>
1946 <br><dt>
1947 </dl>
1948 <p>
1949 <a name = "134"><h3>System Functions</h3></a><a name="index977">
1950 Note: the <code>load</code> function first tries to load a file from the current directory. A <code>.lsp</code> extension is added if there is not already an alphanumeric extension following a period. If that fails, XLisp searches the path, which is obtained from the XLISPPATH environment variable in Unix and HKEY_LOCAL_MACHINE\SOFTWARE\CMU\Nyquist\XLISPPATH under Win32. (The Macintosh version has no search path.)
1951 <p>
1952 <dl>
1953 <dt>
1954 (load<a name="index978"> <i>fname</i> &amp;key :verbose :print) - load a source file
1955 <dd>
1956 <i>fname</i> - the filename string or symbol<br>
1957 :verbose - the verbose flag (default is t)<br>
1958 :print - the print flag (default is <code>nil</code>)<br>
1959 returns - the filename<br>
1960
1961 <br><dt> (save<a name="index979"> <i>fname</i>) - save workspace to a file
1962 <dd>
1963 <i>fname</i> - the filename string or symbol<br>
1964 returns - <code>t</code> if workspace was written, <code>nil</code> otherwise<br>
1965
1966 <br><dt> (restore<a name="index980"> <i>fname</i>) - restore workspace from a file
1967 <dd>
1968 <i>fname</i> - the filename string or symbol<br>
1969 returns - <code>nil</code> on failure, otherwise never returns<br>
1970
1971 <br><dt> (dribble<a name="index981"> [<i>fname</i>]) - create a file with a transcript of a session
1972 <dd>
1973 <i>fname</i> - file name string or symbol
1974 (if missing, close current transcript)<br>
1975 returns - <code>t</code> if the transcript is opened, <code>nil</code> if it is closed<br>
1976
1977 <br><dt> (gc<a name="index982">) - force garbage collection
1978 <dd>
1979 returns - <code>nil</code><br>
1980
1981 <br><dt> (expand<a name="index983"> <i>num</i>) - expand memory by adding segments
1982 <dd>
1983 <i>num</i> - the number of segments to add<br>
1984 returns - the number of segments added<br>
1985
1986 <br><dt> (alloc<a name="index984"> <i>num</i>) - change number of nodes to allocate in each segment
1987 <dd>
1988 <i>num</i> - the number of nodes to allocate<br>
1989 returns - the old number of nodes to allocate<br>
1990
1991 <br><dt> (room<a name="index985">) - show memory allocation statistics
1992 <dd>
1993 returns - <code>nil</code><br>
1994
1995 <br><dt> (type-of<a name="index986"> <i>expr</i>) - returns the type of the expression
1996 <dd>
1997 <i>expr</i> - the expression to return the type of<br>
1998 returns - <code>nil</code> if the value is <code>nil</code> otherwise one of the symbols:<br>
1999 <dl><dd>
2000 SYMBOL - for symbols<br>
2001 OBJECT - for objects<br>
2002 CONS - for conses<br>
2003 SUBR - for built-in functions<br>
2004 FSUBR - for special forms<br>
2005 CLOSURE - for defined functions<br>
2006 STRING - for strings<br>
2007 FIXNUM - for integers<br>
2008 FLONUM - for floating point numbers<br>
2009 CHARACTER - for characters<br>
2010 FILE-STREAM - for file pointers<br>
2011 UNNAMED-STREAM - for unnamed streams<br>
2012 ARRAY - for arrays<br>
2013 </dl>
2014
2015 <br><dt> (peek<a name="index987"> <i>addrs</i>) - peek at a location in memory
2016 <dd>
2017 <i>addrs</i> - the address to peek at (integer)<br>
2018 returns - the value at the specified address (integer)<br>
2019
2020 <br><dt> (poke<a name="index988"> <i>addrs</i> <i>value</i>) - poke a value into memory
2021 <dd>
2022 <i>addrs</i> - the address to poke (integer)<br>
2023 <i>value</i> - the value to poke into the address (integer)<br>
2024 returns - the value<br>
2025
2026 <br><dt> (address-of<a name="index989"> <i>expr</i>) - get the address of an xlisp node
2027 <dd>
2028 <i>expr</i> - the node<br>
2029 returns - the address of the node (integer)<br>
2030
2031 <br><dt> (exit<a name="index990">) - exit xlisp
2032 <dd>
2033 returns - never returns<br>
2034
2035 <br><dt> (setup-console<a name="index991"><a name="index992">) - set default console attributes
2036 <dd>
2037 returns - NIL<br>
2038 Note: Under Windows, Nyquist normally starts up in a medium-sized console window with black text and a white background, with a window title of ``Nyquist.'' This is normally accomplished by calling <code>setup-console</code> in <code>system.lsp</code>. In Nyquist, you can avoid this behavior by setting <code>*setup-console*</code> to NIL in your <code>init.lsp</code> file. If <code>setup-console</code> is not called, Nyquist uses standard input and output as is. This is what you want if you are running Nyquist inside of emacs, for example.<a name="index993"><br>
2039
2040 </dl><a name = "135"><h3>File I/O Functions</h3></a><a name="index994"><a name = "136"><h4>Input from a File</h4></a><a name="index995">To open a file for input, use the <code>open</code> function with the keyword
2041 argument <code>:direction</code> set to <code>:input</code>. To open a file for output,
2042 use the <code>open</code> function with the keyword argument <code>:direction</code> set
2043 to <code>:output</code>. The <code>open</code> function takes a single required argument which
2044 is the name of the file to be opened. This name can be in the form of a
2045 string or a symbol. The <code>open</code> function returns an object of type
2046 <code>FILE-STREAM</code> if it succeeds in opening the specified file. It returns the
2047 value <code>nil</code> if it fails. In order to manipulate the file, it is
2048 necessary to save the value returned by the <code>open</code> function. This is
2049 usually done by assigning it to a variable with the <code>setq</code> special form or by
2050 binding it using <code>let</code> or <code>let*</code>. Here is an example:
2051 <pre>
2052 (setq fp (open "init.lsp" :direction :input))
2053 </pre>
2054
2055 Evaluating this expression will result in the file <code>init.lsp</code>
2056 being opened. The file object that will be returned by the <code>open</code>
2057 function will be assigned to the variable <code>fp</code>.
2058 <p>
2059 It is now possible to use the file for input. To read an
2060 expression from the file, just supply the value of the <code>fp</code>
2061 variable as the optional <i>stream</i> argument to <code>read</code>.
2062 <pre>
2063 (read fp)
2064 </pre>
2065
2066 Evaluating this expression will result in reading the first
2067 expression from the file <code>init.lsp</code>. The expression will be
2068 returned as the result of the <code>read</code> function. More expressions
2069 can be read from the file using further calls to the <code>read</code>
2070 function. When there are no more expressions to read, the <code>read</code>
2071 function will return <code>nil</code> (or whatever value was supplied as the
2072 second argument to <code>read</code>).
2073 <p>
2074 Once you are done reading from the file, you should close it.
2075 To close the file, use the following expression:
2076 <pre>
2077 (close fp)
2078 </pre>
2079
2080 Evaluating this expression will cause the file to be closed.
2081 <p>
2082 <a name = "137"><h4>Output to a File</h4></a><a name="index996"> Writing to a file is pretty much the same as reading from one.
2083 You need to open the file first. This time you should use the
2084 <code>open</code> function to indicate that you will do output to the file.
2085 For example:
2086 <pre>
2087 (setq fp (open "test.dat" :direction :output))
2088 </pre>
2089
2090 Evaluating this expression will open the file <code>test.dat</code> for
2091 output. If the file already exists, its current contents will
2092 be discarded. If it doesn't already exist, it will be created.
2093 In any case, a <code>FILE-STREAM</code> object will be returned by the <code>OPEN</code>
2094 function. This file object will be assigned to the <code>fp</code>
2095 variable.
2096 <p>
2097 It is now possible to write to this file by supplying the value
2098 of the <code>fp</code> variable as the optional <i>stream</i> parameter in the <code>print</code> function.
2099 <pre>
2100 (print "Hello there" fp)
2101 </pre>
2102
2103 Evaluating this expression will result in the string ``Hello
2104 there'' being written to the file <code>test.dat</code>. More data can be
2105 written to the file using the same technique.
2106 <p>
2107 Once you are done writing to the file, you should close it.
2108 Closing an output file is just like closing an input file.
2109 <pre>
2110 (close fp)
2111 </pre>
2112
2113 Evaluating this expression will close the output file and make
2114 it permanent.
2115 <p>
2116 <a name = "138"><h4>A Slightly More Complicated File Example</h4></a> This example shows how to open a file, read each Lisp expression
2117 from the file and print it. It demonstrates the use of files
2118 and the use of the optional <i>stream</i> argument to the <code>read</code>
2119 function.
2120 <pre>
2121 (do* ((fp (open "test.dat" :direction :input))
2122 (ex (read fp) (read fp)))
2123 ((null ex) nil)
2124 (print ex))
2125 </pre>
2126
2127 <p>
2128
2129 <hr>
2130 <a href = "part14.html">Previous Section</a> | <a href = "indx.html">Next Section (Index)</a> | <a href = "home.html#toc">Table of Contents</a> | <a href = "home.html">Title Page</a>
2131 </body></html>