/[cvsroot]/skandha4/info/slisp-9
ViewVC logotype

Contents of /skandha4/info/slisp-9

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Tue May 25 09:39:22 1999 UTC (21 years, 5 months ago) by jsp
Branch: biostr, MAIN
CVS Tags: skandha4, skandha4_1_6, dsg_1_0, HEAD
Branch point for: skandha4_pub, autoconf
Changes since 1.1: +0 -0 lines
ANSI C version of Skandha4


1 This is Info file slisp, produced by Makeinfo version 1.68 from the
2 input file slisp.texi.
3
4 This file documents slisp, (skandha-lisp), an extendable xlisp.
5
6 Copyright @copyright 1994 University of Washington Digital Anatomist
7 Program by Jeff Prothero (jsp@biostr.washington.edu) and Jim Brinkley
8 See slisp/SLISPCOPYING for details
9
10 
11 File: slisp, Node: integerp, Next: intern, Prev: *integer-format*, Up: Xlisp Language Reference
12
13 integerp
14 ========
15
16 integerp
17 type: predicate function (subr)
18 location: built-in
19 source file: xlbfun.c
20 Common LISP compatible: yes
21 supported on: all machines
22
23 SYNTAX
24
25 (integerp <expr> )
26 <expr> - the expression to check
27
28 DESCRIPTION
29
30 The INTEGERP predicate checks if an <expr> is a integer number. T is
31 returned if <expr> is a integer number, NIL is returned otherwise.
32
33 EXAMPLES
34
35 (integerp 1) ; returns T - integer
36 (integerp #x034) ; returns T - integer readmacro
37 (integerp '1) ; returns T - still an integer
38 (setq a 14) ;
39 (integerp a) ; returns T - evaluates to int.
40 (integerp 0) ; returns T - integer zero
41 ;
42 (integerp 1.2) ; returns NIL - float
43 (integerp 0.0) ; returns NIL - float zero
44 (integerp 'a) ; returns NIL - symbol
45 (integerp #\a) ; returns NIL - character
46 (integerp NIL) ; returns NIL - NIL
47 (integerp #(0 1 2)) ; returns NIL - array
48
49
50
51 
52 File: slisp, Node: intern, Next: ;isnew, Prev: integerp, Up: Xlisp Language Reference
53
54 intern
55 ======
56
57 intern
58 type: function (subr)
59 location: built-in
60 source file: xlbfun.c
61 Common LISP compatible: similar
62 supported on: all machines
63
64 SYNTAX
65
66 (intern <name-str> )
67 <name-str> - a string expression
68
69 DESCRIPTION
70
71 The INTERN function takes a string name - <name-str> and creates a
72 new interned symbol. What this means is that the symbol <name-str>
73 will be placed into the symbol hash table *OBARRAY*. It's value will be
74 unbound. It's property list will be NIL (empty). If the symbol already
75 exists, no error or action is taken and the old values and property
76 lists remain intact. The INTERN function returns the symbol as its
77 result.
78
79 EXAMPLES
80
81 (defun lookin (sym) ; create a function to
82 (aref *obarray* ; look inside *OBARRAY*
83 (hash sym (length *obarray*)))); and look for a specific
84 ; symbol - returns a list
85 ;
86 (lookin "FINGERS") ; see if "FINGERS" is a symbol
87 ; returns (:START1) - it isn't
88 (intern "FINGERS") ; intern "FINGERS" as a symbol
89 ; returns FINGERS
90 (lookin "FINGERS") ; returns (FINGERS :START1)
91 (print fingers) ; error: unbound variable
92 ; it exists, but has no value
93 ;
94 (lookin "TOES") ; returns NIL - doesn't exist
95 toes ; error: unbound variable
96 (lookin "TOES") ; returns (TOES)
97 ; the act of looking for a
98 ; value or using a symbol
99 ; causes it to be INTERNed
100 ;
101 (lookin "KNEECAPS") ; returns (MAX MAPLIST) -
102 ; KNEECAPS doesn't exist
103 (setq kneecaps 'a-bone) ; create symbol with a value
104 (lookin "KNEECAPS") ; returns (KNEECAPS MAX MAPLIST)
105
106 NOTE: When you INTERN a symbol like "fingers", this gets placed in
107 the *OBARRAY* symbol table as a lower case symbol. Note that this is
108 different from doing an INTERN on "FINGERS". "fingers" and "FINGERS"
109 are two different symbols in *OBARRAY*. Remember also that normal
110 symbols created by XLISP are upper case names. So, an intern of
111 'fingers or 'FINGERS are normal symbols, and will be the upper-case
112 symbol FINGERS.
113
114 COMMON LISP COMPATIBILITY: Common LISP allows an optional package
115 specification, which XLISP does not support.
116
117
118
119 
120 File: slisp, Node: ;isnew, Next: &key, Prev: intern, Up: Xlisp Language Reference
121
122 :isnew
123 ======
124
125 :isnew
126 type: message selector
127 location: built-in
128 source file: xlobj.c
129 Common LISP compatible: no
130 supported on: all machines
131
132 SYNTAX
133
134 (send <object> :isnew <args> )
135 <object> - an existing object
136 <args> - the arguments to be passed to the init. code
137 (send <class> :isnew <ivars> [ <cvars> [ <superclass> ] ] )
138 <class> - an existing XLISP class
139 <ivars> - list of instance variables for new class
140 <cvars> - list of class variable symbols for new class
141 <superclass> - superclass for new object
142 (the default is 'OBJECT')
143
144 DESCRIPTION
145
146 The :ISNEW message selector causes an instance to run its
147 initialization method. If an :ISNEW message is sent to a class, the
148 class definition and state will be reset as specified in the arguments
149 of the message.
150
151 EXAMPLES
152
153 (setq a-class ; create a new class A-CLASS
154 (send class :new '(state))) ; with STATE
155 (send a-class :answer :isnew '() ; set up initialization
156 '((setq state nil) self)) ;
157 (send a-class :answer :set-it '(value) ; create :SET-IT message
158 '((setq state value))) ;
159 (setq an-obj (send a-class :new)) ; create AN-OBJ out of A-CLASS
160 (send an-obj :show) ; returns object - STATE = NIL
161 (send an-obj :set-it 5) ; STATE is set to 5
162 (send an-obj :show) ; returns object - STATE = 5
163 (SEND an-obj :ISNEW) ; re-initialize AN-OBJ
164 (send an-obj :show) ; returns object - STATE = NIL
165
166
167
168 
169 File: slisp, Node: &key, Next: labels, Prev: ;isnew, Up: Xlisp Language Reference
170
171 &key
172 ====
173
174 &key
175 type: keyword
176 location: built-in
177 source file: xleval.c
178 Common LISP compatible: yes
179 supported on: all machines
180
181 SYNTAX
182
183 &key <key-arg> ...
184 &key ( <key-arg> [ <key-value> [ <exist-symbol> ] ] ) ...
185 &key ( ( <key-symbol> <key-arg> ) [ <key-value> [ <exist-symbol> ] ] ) ...
186 <key-arg> - keyword argument
187 <key-symbol> - keyword argument symbol
188 <key-value> - keyword argument initialization
189 <exist-symbol> - keyword argument existence symbol
190
191 DESCRIPTION
192
193 In XLISP, there are several times that you define a formal argument
194 list for a body of code (like DEFUN, DEFMACRO, :ANSWER and LAMBDA).
195 All of the formal arguments that are defined are required to appear in
196 the invocation of the defined function or operation. If there are any
197 &OPTIONAL arguments defined, they will be filled in order. There are
198 other optional arguments called KEYWORD arguments. These arguments are
199 not position dependent but can be specified in any order by a preceding
200 keyword (a symbol with a leading ':'). If there is no <key-symbol>
201 specified in the argument list, the keyword will be constructed from the
202 <key-arg> name by adding a leading ':'. (For example a <key-arg> of
203 FURTER will generate a keyword symbol of :FURTER).
204
205 Like the &OPTIONAL arguments, there can be initialization values
206 provided via the <key-value> argument. If there is no <key-value>
207 argument and no value is provided by the function call, the <key-arg>
208 value will be NIL.
209
210 The <exist-symbol>, if it is specified, will contain a T if the
211 <key-arg> value was supplied by the function call and a NIL if it was
212 not supplied by the function call. This <exist-symbol> allows the
213 programmer to test for an argument's existence. At the end of the
214 function or operation execution, these local symbols and their values
215 are are removed.
216
217 EXAMPLES
218
219 (defun foo ; define function FOO
220 (a &key b c ) ; with some optional args
221 (print a) (print b) (print c)) ;
222 (foo) ; error: too few arguments
223 (foo 1) ; prints 1 NIL NIL
224 (foo 1 2) ; prints 1 NIL NIL
225 (foo 1 :b 2 :c 3) ; prints 1 2 3
226 (foo 1 :c 3 :b 2) ; prints 1 2 3
227 (foo 1 :b 3 :b 2) ; prints 1 3 NIL
228 ;
229 (defun fee ; define function FEE
230 (a &key (b 9 b-passed) ) ; with some optional args
231 (print a) (print b) ;
232 (if b-passed (print "b was passed") ;
233 (print "b not passed"))) ;
234 (fee) ; error: too few arguments
235 (fee 1) ; prints 1 9 "b not passed"
236 (fee 1 2) ; prints 1 9 "b not passed"
237 (fee 1 :b 2) ; prints 1 2 "b was passed"
238 ;
239 (defun fi ; define function FI
240 (a &key ((:mykey b) 9 b-passed) ) ; with some optional args
241 (print a) (print b) ;
242 (if b-passed (print "b was passed") ;
243 (print "b not passed"))) ;
244 (fi) ; error: too few arguments
245 (fi 1) ; prints 1 9 "b not passed"
246 (fi 1 2) ; prints 1 9 "b not passed"
247 (fi 1 :b 2) ; prints 1 9 "b not passed"
248 (fi 1 :mykey 2) ; prints 1 2 "b was passed"
249
250 NOTE: There is a &ALLOW-OTHER-KEYS keyword in XLISP and Common LISP.
251 In the case of XLISP, this keyword is extraneous since the default for
252 keyword arguments is to allow other keys (without errors).
253
254
255
256 
257 File: slisp, Node: labels, Next: lambda, Prev: &key, Up: Xlisp Language Reference
258
259 labels
260 ======
261
262 labels
263 type: special form (fsubr)
264 location: built-in
265 source file: xlcont.c
266 Common LISP compatible: yes
267 supported on: all machines
268
269 SYNTAX
270
271 (labels ( [ <function> ... ] ) <expr> ... )
272 <function> - a function definition binding which is of the
273 form ( <symbol> <arg-list> <body> )
274 <symbol> - the symbol specifying the function name
275 <arg-list> - the argument list for the function
276 <body> - the body of the function
277 <expr> - an expression
278
279 DESCRIPTION
280
281 The LABELS special form is basically a local block construct that
282 allows local <function> definitions followed by a block of code to
283 evaluate. The first form after the labels is the 'binding' form. It
284 contains a series of <functions>. LABELS allows the <functions> to be
285 defined in a mutually recursive manner. (The similar FLET form does
286 not allow this.) The LABELS form will go through and define the
287 <symbol>s of the <functions> and then sequentially execute the
288 <expr>'s. The value of the last <expr> evaluated is returned. When
289 the LABELS is finished execution, the <symbol>'s that were defined will
290 no longer exist.
291
292 EXAMPLES
293
294 (labels ( (fozz (x) (+ x x) )) ; a LABELS with FOZZ local func.
295 (fozz 2)) ; returns 4
296 ; FOZZ no longer exists
297 (fozz 2) ; error: unbound function - FOZZ
298 ;
299 ; an empty LABELS
300 (labels () (print 'a)) ; prints A
301 ;
302 ; LABELS form including
303 (labels ( (inc (arg) (est arg)) ; INC definition using EST
304 (est (var) (* .1 var)) ) ; EST definition
305 (inc 99) ) ; returns 9.9
306 ;
307 ; FLET form including
308 (flet ( (inc (arg) (est arg)) ; INC definition using EST
309 (est (var) (* .1 var)) ) ; EST definition
310 (inc 99) ; error: unbound function - EST
311
312 NOTE: FLET does not allow recursive definitions of functions. The
313 LABEL special form does allow this.
314
315
316
317 
318 File: slisp, Node: lambda, Next: last, Prev: labels, Up: Xlisp Language Reference
319
320 lambda
321 ======
322
323 lambda
324 type: special form (fsubr)
325 location: built-in
326 source file: xlcont.c
327 Common LISP compatible: yes
328 supported on: all machines
329
330 SYNTAX
331
332 (lambda <arg-list> [ <body> ] )
333 <arg-list> - A list of the formal arguments to the function
334 of the form: ( [ <arg1> ... ]
335 [ &optional <oarg1> ... ]
336 [ &rest <rarg> ]
337 [ &key ... ]
338 [ &aux <aux1> ... ] )
339 <body> - A series of LISP forms (expressions) that
340 are executed in order.
341
342 DESCRIPTION
343
344 LAMBDA returns a function definition - an executable function - that
345 has no name.
346
347 All of the <argN> formal arguments that are defined are required to
348 appear in a call to the defined function. If there are any &OPTIONAL
349 arguments defined, they will be filled in order. If there is a &REST
350 argument defined, and all the required formal arguments and &OPTIONAL
351 arguments are filled, any and all further parameters will be passed into
352 the function via the <rarg> argument. Note that there can be only one
353 <rarg> argument for &REST. If there are insufficient parameters for any
354 of the &OPTIONAL or &REST arguments, they will contain NIL. The &AUX
355 variables are a mechanism for you to define variables local to the
356 function definition. At the end of the function execution, these local
357 symbols and their values are are removed.
358
359 EXAMPLES
360
361 (funcall (lambda (a b) (* a b)) 4 8 ) ; evaluate a lambda function
362 ; returns 32
363 (funcall (lambda '(a b) (+ a b)) 1 2) ; evaluate another
364 ; returns 3
365 (funcall (lambda (a b) ; evaluate a more complex one
366 (print "a no-name fnc") ; prints "a no-name fnc"
367 (* a b)) 3 8) ; and returns 24
368
369 NOTE: Using a SETQ on a LAMBDA expression is not the same as a
370 DEFUN. A SETQ on a LAMBDA will give the variable the value of the
371 LAMBDA closure. This does not mean that the variable name can be used
372 as a function.
373
374
375
376 
377 File: slisp, Node: last, Next: length, Prev: lambda, Up: Xlisp Language Reference
378
379 last
380 ====
381
382 last
383 type: function (subr)
384 location: built-in
385 source file: xllist.c
386 Common LISP compatible: yes
387 supported on: all machines
388
389 SYNTAX
390
391 (last <list-expr> )
392 <list-expr> - a list or list expression
393
394 DESCRIPTION
395
396 The LAST function returns a list containing the last node or element
397 of a list. If the last node is a sub-list, this is returned unaffected.
398
399 EXAMPLES
400
401 (last NIL) ; returns NIL
402 (last 'a) ; error: bad argument type
403 (last '(A)) ; returns (A)
404 (last '(A B C D E)) ; returns (E)
405 (last '( A (B C) (D E (F)))) ; returns ((D E (F)))
406 ;
407 (setq children '(junie vicki ;
408 cindy chris)) ;
409 (last children) ; returns CHRIS
410
411
412
413 
414 File: slisp, Node: length, Next: let, Prev: last, Up: Xlisp Language Reference
415
416 length
417 ======
418
419 length
420 type: function (subr)
421 location: built-in
422 source file: xllist.c
423 Common LISP compatible: yes
424 supported on: all machines
425
426 SYNTAX
427
428 (length <expr> )
429 <expr> - a list expression or string expression
430
431 DESCRIPTION
432
433 LENGTH returns the length of the <expr>. If the <expr> is a string,
434 the number of characters is returned. If the <expr> is a list, the
435 number of top level elements (atoms or sublists) is returned. If the
436 list is NIL, a 0 is returned.
437
438 EXAMPLES
439
440 (length NIL) ; returns 0
441 (length 'a) ; error: bad argument type
442 (length '(a)) ; returns 1
443 (length '(1 2 3 4 5 6)) ; returns 6
444 (length '(a (b c) (d (e) f) g)) ; returns 4
445 ;
446 (length "12345") ; returns 5
447
448
449
450 
451 File: slisp, Node: let, Next: let*, Prev: length, Up: Xlisp Language Reference
452
453 let
454 ===
455
456 let
457 type: special form (fsubr)
458 location: built-in
459 source file: xlcont.c
460 Common LISP compatible: yes
461 supported on: all machines
462
463 SYNTAX
464
465 (let ( [ <binding> ... ] ) <expr> ... )
466 <binding> - a variable binding which is of the form
467 <symbol> or ( <symbol> <init-expr> )
468 <symbol> - a symbol
469 <init-expr> - an initialization expression for <symbol>
470 <expr> - an expression
471
472 DESCRIPTION
473
474 The LET special form is basically a local block construct that
475 contains symbols (with optional initializations) and a block of code
476 (expressions) to evaluate. The first form after the LET is the
477 'binding' form. It contains a series of <symbol>'s or <binding>'s. The
478 <binding> is a <symbol> followed by an initialization expression
479 <init-expr>. If there is no <init-expr>, the <symbol> will be
480 initialized to NIL. There is no specification as to the order of
481 execution of the bindings. The LET form will go through and create and
482 initialize the symbols and then sequentially execute the <expr>'s. The
483 value of the last <expr> evaluated is returned. When the LET is
484 finished execution, the <symbol>'s that were defined will no longer
485 exist or retain their values.
486
487 EXAMPLES
488
489 (let (x y z) ; LET with local vars
490 (print x) (print y) (print z)) ; prints NIL NIL NIL
491 (let ((a 1) (b 2) (c 3)) ; LET with local vars & init.
492 (print (+ a b c))) ; prints and returns 6
493 (let ( (a 1) (b 2) (c (+ a b))) ; LET with local vars & init.
494 (print (+ a b c))) ; error: unbound variable - A
495 ; because (+ A B) init code
496 ; depends on vars A and B
497 ; which haven't been created
498 ; yet - because of ordering
499
500
501
502 
503 File: slisp, Node: let*, Next: list, Prev: let, Up: Xlisp Language Reference
504
505 let*
506 ====
507
508 let*
509 type: special form (fsubr)
510 location: built-in
511 source file: xlcont.c
512 Common LISP compatible: yes
513 supported on: all machines
514
515 SYNTAX
516
517 (let* ( [ <binding> ... ] ) <expr> ... )
518 <binding> - a variable binding which is of the form
519 <symbol> or ( <symbol> <init-expr> )
520 <symbol> - a symbol
521 <init-expr> - an initialization expression for <symbol>
522 <expr> - an expression
523
524 DESCRIPTION
525
526 The LET* special form is basically a local block construct that
527 contains symbols (with optional initializations) and a block of code
528 (expressions) to evaluate. The first form after the LET* is the
529 'binding' form. It contains a series of <symbol>'s or <binding>'s. The
530 <binding> is a <symbol> followed by an initialization expression
531 <init-expr>. If there is no <init-expr>, the <symbol> will be
532 initialized to NIL. The execution of the bindings will occur from the
533 first to the last binding. The LET* form will go through and create and
534 initialize the symbols and then sequentially execute the <expr>'s. The
535 value of the last <expr> evaluated is returned. When the LET* is
536 finished execution, the <symbol>'s that were defined will no longer
537 exist or retain their values.
538
539 EXAMPLES
540
541 (let* (x y z) ; LET* with local vars
542 (print x) (print y) (print z)) ; prints NIL NIL NIL
543 (let* ((a 1) (b 2) (c 3)) ; LET* with local vars & init.
544 (print (+ a b c))) ; prints and returns 6
545 (let* ( (a 1) (b 2) (c (+ a b))) ; LET* with local vars & init.
546 (print (+ a b c))) ; prints and returns 6
547 ; because (+ A B) init code
548 ; depends on vars A and B
549 ; which have been created -
550 ; because of ordering of LET*
551
552
553
554 
555 File: slisp, Node: list, Next: listp, Prev: let*, Up: Xlisp Language Reference
556
557 list
558 ====
559
560 list
561 type: function (subr)
562 location: built-in
563 source file: xllist.c
564 Common LISP compatible: yes
565 supported on: all machines
566
567 SYNTAX
568
569 (list [ <expr1> ... ])
570 <exprN> - an expression
571
572 DESCRIPTION
573
574 The LIST function takes the expressions and constructs a list out of
575 them. This constructed list is returned.
576
577 EXAMPLES
578
579 (list) ; returns NIL
580 (list NIL) ; returns (NIL)
581 (list 'a) ; returns (A)
582 (list 'a 'b) ; returns (A B)
583 (list 'a 'b 'c) ; returns (A B C)
584 (list 'a 'b NIL) ; returns (A B NIL)
585 (list '(a b) '(c d) '( (e f) )) ; returns ((A B) (C D) ((E F)))
586 (list (+ 1 2) (+ 3 4)) ; returns (3 7)
587
588
589
590 
591 File: slisp, Node: listp, Next: load, Prev: list, Up: Xlisp Language Reference
592
593 listp
594 =====
595
596 listp
597 type: predicate function (subr)
598 location: built-in
599 source file: xlbfun.c
600 Common LISP compatible: yes
601 supported on: all machines
602
603 SYNTAX
604
605 (listp <expr> )
606 <expr> - the expression to check
607
608 DESCRIPTION
609
610 The LISTP predicate checks if the <expr> is a list. T is returned if
611 <expr> is a list or an empty list (the NIL value), NIL is returned
612 otherwise.
613
614 EXAMPLES
615
616 (listp '(a b)) ; returns T - list
617 (listp NIL) ; returns T - NIL
618 (listp '(a . b)) ; returns T - dotted pair list
619 ;
620 (listp (lambda (x) (print x))) ; returns NIL - closure - lambda
621 (listp #(1 2 3)) ; returns NIL - array
622 (listp *standard-output*) ; returns NIL - stream
623 (listp 1.2) ; returns NIL - float
624 (listp #'quote) ; returns NIL - fsubr
625 (listp 1) ; returns NIL - integer
626 (listp object) ; returns NIL - object
627 (listp "str") ; returns NIL - string
628 (listp #'car) ; returns NIL - subr
629 (listp 'a) ; returns NIL - symbol
630
631 NOTE: NIL or '() is used in many places as a list-class or atom-class
632 expression. Both ATOM and LISTP, when applied to NIL, return T. If you
633 wish to check for a non-empty list, use the CONSP predicate.
634
635
636
637 
638 File: slisp, Node: load, Next: logand, Prev: listp, Up: Xlisp Language Reference
639
640 load
641 ====
642
643 load
644 type: function (subr)
645 location: built-in
646 source file: xlsys.c and xlread.c
647 Common LISP compatible: similar
648 supported on: all machines
649
650 SYNTAX
651
652 (load <file> [ :verbose <v-flag> ] [ :print <p-flag> ] ))
653 <file> - a string expression or symbol
654 <v-flag> - an optional key-word expression - default is T
655 <p-flag> - an optional key-word expression - default is NIL
656
657 DESCRIPTION
658
659 The LOAD function opens the <file>, reads and evaluates all the forms
660 within the <file>. <file> may be a string expression or a symbol. When
661 <file> is a string, you may specify a complete file location or
662 extensions (like "/usr/local/bin/myfile.lsp" or "A:\LISP\TIM.LSP"). If
663 <file> is a string and includes a file type or an extension (like
664 ".lsp"), then LOAD accesses the specified file. If there is no
665 extension on <file>, it will add ".lsp". If the :VERBOSE keyword is
666 present and <v-flag> is non-NIL, a load message of the form ; loading
667 "xxxx.lsp" will be printed to *STANDARD-OUTPUT*. If the :PRINT keyword
668 is present and <p-flag> is non-NIL, the resulting value of each
669 top-level form in <file> will be printed to *STANDARD-OUTPUT*. If the
670 file load was successful, then T is returned as the result. If the file
671 load was not successful, a NIL is returned.
672
673 EXAMPLES
674
675 (load 'gloop) ; prints ; loading "GLOOP.lsp"
676 ; returns NIL there is no file
677 ;
678 (defun foo (x) (print x)) ; create a function
679 (savefun foo) ; create a file FOO.lsp
680 (load 'foo) ; prints ; loading "FOO.lsp"
681 ; returns T
682 (load 'foo :verbose NIL) ; no printing returns T
683 (load 'foo :print T) ; prints FOO returns T
684 (load 'save :verbose T :print T) ; prints ; loading "FOO.lsp"
685 ; prints FOO returns T
686 (load "foo") ; prints ; loading "foo.lsp"
687 ; returns NIL didn't work
688 ; because the file is "FOO.lsp"
689 (load "FOO") ; prints ; loading "FOO.lsp"
690 ; returns T did work
691 (load "FOO.lsp") ; prints ; loading "FOO.lsp"
692 ; returns T did work
693
694 FILE NAMES: In the PC and DOS world, all file names and extensions
695 ("FOO.BAT") are automatically made uppercase. In using XLISP, this
696 means you don't have to worry about whether the name is "foo.bat",
697 "FOO.BAT" or even "FoO.bAt" - they will all work. However, in other
698 file systems (UNIX in particular), uppercase and lowercase do make a
699 difference. So, in UNIX if you do a (open 'foo-file :direction
700 :output), this will create a file named FOO-FILE because XLISP
701 uppercases its symbols. If you do a (open "foo-file" :direction
702 :output), this will create a file named "foo-file" because UNIX doesn't
703 uppercase its file names. Another case is if you do (savefun mydefun),
704 this will create the file "MYDEFUN.lsp". So, if you are having trouble
705 with opening and accessing files, check to make sure the file name is
706 in the proper case.
707
708 COMMON LISP COMPATIBILITY: Common LISP has a LOAD function that is
709 similar to XLISP's LOAD. The only difference is that Common LISP uses
710 an optional keyword parameter :IF-DOES-NOT-EXIST which XLISP does not
711 support.
712
713 NOTE: In XLISP, the keyword parameters are order sensitive. If both
714 :VERBOSE and :PRINT keywords are used, :VERBOSE must come first.
715
716 KEYSTROKE EQUIVALENT: In the Macintosh version of XLISP, a COMMAND-l
717 brings up a dialog box for loading a file. COMMAND-n operates
718 similarly, except that the load is done with :VERBOSE and :PRINT flags
719 set. These can also be accomplished by a pull-down menu selection.
720
721
722
723 
724 File: slisp, Node: logand, Next: logior, Prev: load, Up: Xlisp Language Reference
725
726 logand
727 ======
728
729 logand
730 type: function (subr)
731 location: built-in
732 source file: xlmath.c
733 Common LISP compatible: yes
734 supported on: all machines
735
736 SYNTAX
737
738 (logand <expr1> ... )
739 <exprN> - an integer expression
740
741 DESCRIPTION
742
743 The LOGAND function returns the logical (bitwise) AND of the list of
744 expressions. If there is only one argument, it is returned unaltered.
745 If there are two or more arguments, the LOGAND function performs the
746 logical and operation successively applying the bitwise operation.
747
748 EXAMPLES
749
750 (logand 0 0) ; returns 0
751 (logand 0 1) ; returns 0
752 (logand 1 0) ; returns 0
753 (logand 1 1) ; returns 1
754 (logand 55 #x0F) ; returns 7
755 (logand 7 #b0011) ; returns 3
756 (logand 1 2 4 8 16) ; returns 0
757 (logand 15 7 3) ; returns 3
758
759 NOTE: XLISP does not check when read-macro expansions (like #x0FF)
760 are out of bounds. It gives no error message and will just truncate
761 the number to the low-order bits that it can deal with (usually 32 bits
762 or 8 hex digits).
763
764
765
766 
767 File: slisp, Node: logior, Next: lognot, Prev: logand, Up: Xlisp Language Reference
768
769 logior
770 ======
771
772 logior
773 type: function (subr)
774 location: built-in
775 source file: xlmath.c
776 Common LISP compatible: yes
777 supported on: all machines
778
779 SYNTAX
780
781 (logior <expr1> ... )
782 <exprN> - an integer expression
783
784 DESCRIPTION
785
786 The LOGIOR function returns the logical (bitwise) INCLUSIVE-OR of the
787 list of expressions. If there is only one argument, it is returned
788 unaltered. If there are two or more arguments, the LOGIOR function
789 performs the inclusive-or successively applying the bitwise operation.
790
791 EXAMPLES
792
793 (logior 0 0) ; returns 0
794 (logior 0 1) ; returns 1
795 (logior 1 0) ; returns 1
796 (logior 1 1) ; returns 1
797 ;
798 (logior 1 2 4 8 16 32 64) ; returns 127
799 (logior 5 #b010) ; returns 7
800 (logior 99 #x1FF) ; returns 511
801 (logior 99 #x400) ; returns 1123
802
803 NOTE: XLISP does not check when read-macro expansions (like #x0FF)
804 are out of bounds. It gives no error message and will just truncate
805 the number to the low-order bits that it can deal with (usually 32 bits
806 or 8 hex digits).
807
808
809
810 
811 File: slisp, Node: lognot, Next: logxor, Prev: logior, Up: Xlisp Language Reference
812
813 lognot
814 ======
815
816 lognot
817 type: function (subr)
818 location: built-in
819 source file: xlmath.c
820 Common LISP compatible: yes
821 supported on: all machines
822
823 SYNTAX
824
825 (lognot <expr> )
826 <expr> - an integer expression
827
828 DESCRIPTION
829
830 The LOGNOT function returns the logical (bitwise) INVERSION of the
831 expression.
832
833 EXAMPLES
834
835 (lognot 255) ; returns -256
836 (lognot #xffff0000) ; returns 65535
837 (lognot #x00000000) ; returns -1
838 (lognot 1) ; returns -2
839 ;
840 (logand (lognot 256) 65535) ; returns 65279
841 (lognot #xFFFFFFFE) ; returns 1
842 (lognot #xFFFFFFFC) ; returns 3
843
844 NOTE: XLISP does not check when read-macro expansions (like #x0FF)
845 are out of bounds. It gives no error message and will just truncate
846 the number to the low-order bits that it can deal with (usually 32 bits
847 or 8 hex digits).
848
849
850
851 
852 File: slisp, Node: logxor, Next: loop, Prev: lognot, Up: Xlisp Language Reference
853
854 logxor
855 ======
856
857 logxor
858 type: function (subr)
859 location: built-in
860 source file: xlmath.c
861 Common LISP compatible: yes
862 supported on: all machines
863
864 SYNTAX
865
866 (logxor <expr1> ... )
867 <exprN> - an integer expression
868
869 DESCRIPTION
870
871 The LOGXOR function returns the logical (bitwise) EXCLUSIVE-OR of the
872 list of expressions. If there is only one argument, it is returned
873 unaltered. If there are two or more arguments, the LOGXOR function
874 performs the exclusive-or successively applying the bitwise operation.
875
876 EXAMPLES
877
878 (logxor 0 0) ; returns 0
879 (logxor 0 1) ; returns 1
880 (logxor 1 0) ; returns 1
881 (logxor 1 1) ; returns 0
882 (logxor #b0011 #b0101) ; returns 6
883 (logxor 255 #xF0) ; returns 15
884 (logxor 255 #x0F) ; returns 240
885 (logxor 255 (logxor 255 99)) ; returns 99
886
887 NOTE: XLISP does not check when read-macro expansions (like #x0FF)
888 are out of bounds. It gives no error message and will just truncate
889 the number to the low-order bits that it can deal with (usually 32 bits
890 or 8 hex digits).
891
892
893
894 
895 File: slisp, Node: loop, Next: lower-case-p, Prev: logxor, Up: Xlisp Language Reference
896
897 loop
898 ====
899
900 loop
901 type: special form (fsubr)
902 location: built-in
903 source file: xlcont.c
904 Common LISP compatible: yes
905 supported on: all machines
906
907 SYNTAX
908
909 (loop <body> ... )
910 <body> - a series of expressions
911
912 DESCRIPTION
913
914 The LOOP special form specifies a 'repeat-forever' construct. The
915 expressions in <body> will be evaluated. When the last expression is
916 evaluated in <body>, LOOP will then repeat the <body>. When a RETURN is
917 evaluated within a LOOP, the specified value will be returned. LOOP
918 itself does not generate a return value. Other exit mechanisms include
919 GO, THROW, RETURN-FROM and errors.
920
921 EXAMPLES
922
923 (setq i 65) ; initial value
924 (loop ; LOOP
925 (princ (int-char i) ) ; print the character
926 (if (= i 90) (return "done")) ; test for limit
927 (setq i (1+ i) ) ) ; increment and repeat
928 ; prints
929 ; ABCDEFGHIJKLMNOPQRSTUVWXYZ
930 ; returns "done"
931
932 NOTE: If you create a LOOP with no exit mechanism, you will probably
933 have to abort your XLISP session.
934
935
936
937 
938 File: slisp, Node: lower-case-p, Next: macroexpand, Prev: loop, Up: Xlisp Language Reference
939
940 lower-case-p
941 ============
942
943 lower-case-p
944 type: predicate function (subr)
945 location: built-in
946 source file: xlstr.c
947 Common LISP compatible: yes
948 versions: all machines
949
950 SYNTAX
951
952 (lower-case-p <char> )
953 <char> - a character expression
954
955 DESCRIPTION
956
957 The LOWER-CASE-P predicate checks if the <char> expression is a lower
958 case character. If <char> is lower case a T is returned, otherwise a
959 NIL is returned. Lower case characters are 'a' (ASCII decimal value 97)
960 through 'z' (ASCII decimal value 122).
961
962 EXAMPLES
963
964 (lower-case-p #\a) ; returns T
965 (lower-case-p #\A) ; returns NIL
966 (lower-case-p #\1) ; returns NIL
967 (lower-case-p #\[) ; returns NIL
968
969
970
971 
972 File: slisp, Node: macroexpand, Next: macroexpand-1, Prev: lower-case-p, Up: Xlisp Language Reference
973
974 macroexpand
975 ===========
976
977 macroexpand
978 type: function (subr)
979 location: built-in
980 source file: xlbfun.c
981 Common LISP compatible: similar
982 supported on: all machines
983
984 SYNTAX
985
986 (macroexpand <form> )
987 <form> - a macro form
988
989 DESCRIPTION
990
991 The MACROEXPAND function takes a <form> and recursively expands the
992 macro definitions used in the <form>. The function returns the
993 expansion. If the <form> does not contain a macro, the form is returned
994 unaltered.
995
996 EXAMPLES
997
998 (defmacro plus (n1 n2) `(+ ,n1 ,n2)) ; define PLUS macro
999 (plus 1 2) ; returns 3
1000 (macroexpand '(plus 3 4)) ; returns (+ 3 4)
1001 ;
1002 (defmacro pl (p1 p2) `(plus ,p1 ,p2)) ; define PL macro using PLUS
1003 (pl 3 4) ; returns 7
1004 (macroexpand '(pl 3 4)) ; returns (+ 3 4)
1005 (macroexpand-1 '(pl 3 4)) ; returns (PLUS 3 4)
1006
1007 COMMON LISP COMPATIBILITY: Common LISP returns 2 values for its
1008 result of MACROEXPAND - the expanded form and a T or NIL value that
1009 indicates if the <form> was a macro. XLISP returns only the expanded
1010 form.
1011
1012 COMMON LISP COMPATIBILITY: Common LISP supports an optional argument
1013 in MACROEXPAND for the environment of the expansion. XLISP does not
1014 support this optional argument.
1015
1016
1017
1018 
1019 File: slisp, Node: macroexpand-1, Next: macrolet, Prev: macroexpand, Up: Xlisp Language Reference
1020
1021 macroexpand-1
1022 =============
1023
1024 macroexpand-1
1025 type: function (subr)
1026 location: built-in
1027 source file: xlbfun.c
1028 Common LISP compatible: similar
1029 supported on: all machines
1030
1031 SYNTAX
1032
1033 (macroexpand-1 <form> )
1034 <form> - a macro form
1035
1036 DESCRIPTION
1037
1038 The MACROEXPAND-1 function takes a <form> and expands the first
1039 level of the macro definition used in the <form>. The function returns
1040 the expansion. If the <form> does not contain a macro, the form is
1041 returned unaltered.
1042
1043 EXAMPLES
1044
1045 (defmacro plus (n1 n2) `(+ ,n1 ,n2)) ; define PLUS macro
1046 (plus 1 2) ; returns 3
1047 (macroexpand '(plus 3 4)) ; returns (+ 3 4)
1048 (macroexpand-1 '(plus 3 4)) ; returns (+ 3 4)
1049 ;
1050 (defmacro pl (p1 p2) `(plus ,p1 ,p2)) ; define PL macro using PLUS
1051 (pl 3 4) ; returns 7
1052 (macroexpand '(pl 3 4)) ; returns (+ 3 4)
1053 (macroexpand-1 '(pl 3 4)) ; returns (PLUS 3 4)
1054
1055 COMMON LISP COMPATIBILITY: Common LISP returns 2 values for its
1056 result of MACROEXPAND-1 - the expanded form and a T or NIL value that
1057 indicates if the <form> was a macro. XLISP returns only the expanded
1058 form.
1059
1060 COMMON LISP COMPATIBILITY: Common LISP supports an optional argument
1061 in MACROEXPAND-1 for the environment of the expansion. XLISP does not
1062 support this optional argument.
1063
1064
1065
1066 
1067 File: slisp, Node: macrolet, Next: make-array, Prev: macroexpand-1, Up: Xlisp Language Reference
1068
1069 macrolet
1070 ========
1071
1072 macrolet
1073 type: special form (fsubr)
1074 location: built-in
1075 source file: xlcont.c
1076 Common LISP compatible: yes
1077 supported on: all machines
1078
1079 SYNTAX
1080
1081 (macrolet ( [ <macro> ... ] ) <expr> ... )
1082 <macro> - a macro definition binding which is of the
1083 form ( <symbol> <arg-list> <body> )
1084 <symbol> - the symbol specifying the function name
1085 <arg-list> - the argument list for the function
1086 <body> - the body of the function
1087 <expr> - an expression
1088
1089 DESCRIPTION
1090
1091 The MACROLET special form is basically a local block construct that
1092 allows local <macro> definitions followed by a block of code to
1093 evaluate. The first form after the macrolet is the 'binding' form. It
1094 contains a series of <macro>s. The MACROLET form will sequentially
1095 execute the <expr>'s after defining the <macro>s. The value of the last
1096 <expr> evaluated is returned. When the MACROLET is finished execution,
1097 the <symbol>'s that were defined will no longer exist.
1098
1099 EXAMPLES
1100
1101 ; a MACROLET form including
1102 (macrolet ((pls (n1 n2) `(+ ,n1 ,n2))) ; PLS macro
1103 (pls 4 5)) ; returns 9
1104 ; the PLS macro no longer exists
1105 (pls 4 5) ; error: unbound function - PLS
1106 ;
1107 ; an empty MACROLET
1108 (macrolet () (print 'a)) ; prints A
1109
1110
1111
1112 
1113 File: slisp, Node: make-array, Next: make-string-input-stream, Prev: macrolet, Up: Xlisp Language Reference
1114
1115 make-array
1116 ==========
1117
1118 make-array
1119 type: function (subr)
1120 location: built-in
1121 source file: xlbfun.c
1122 Common LISP compatible: similar
1123 supported on: all machines
1124
1125 SYNTAX
1126
1127 (make-array <size> )
1128 <size> - the size (integer) of the array to be created
1129
1130 DESCRIPTION
1131
1132 MAKE-ARRAY creates an array of the specified size and returns the
1133 array. Array elements may be any valid lisp data type - including
1134 lists or arrays. Arrays made by MAKE-ARRAY and accessed by AREF are
1135 base 0. This means the first element is accessed by element number 0
1136 and the last element is accessed by element number n-1 (where n is the
1137 array size). Array elements are initialized to NIL.
1138
1139 EXAMPLES
1140
1141 (setq my-array (make-array 16)) ; make the array
1142 (aref my-array 0) ; return 0th (first) element
1143 (aref my-array 15) ; return 15th (last) element
1144 (aref my-array 16) ; error: non existant element
1145 (dotimes (i 16) ; set each element to its index
1146 (setf (aref my-array i) i)) ; by the setf function
1147 ;
1148 (setq new (make-array 4)) ; make another array
1149 (setf (aref new 0) (make-array 4)) ; make new[0] an array of 4
1150 (setf (aref (aref new 0) 1) 'a) ; set new[0,1] = 'a
1151 (setf (aref new 2) '(a b c)) ; set new[2] = '(a b c)
1152 my-array ; look at array
1153
1154 READ MACRO: There is a built-in read-macro for arrays - # (the
1155 hash symbol). This allows you to create arbitrary arrays with initial
1156 values without going through a MAKE-ARRAY function. There is also
1157 the VECTOR function to create initialized arrays. For example:
1158
1159 (aref #(0 1 2) 1) ; returns 1
1160
1161 COMMON LISP COMPATIBILITY: XLISP only supports one-dimensional
1162 arrays. Common LISP supports multi-dimension arrays. Common LISP also
1163 supports various keyword parameters that are not supported in XLISP.
1164
1165
1166
1167 
1168 File: slisp, Node: make-string-input-stream, Next: make-string-output-stream, Prev: make-array, Up: Xlisp Language Reference
1169
1170 make-string-input-stream
1171 ========================
1172
1173 make-string-input-stream
1174 type: function (subr)
1175 location: built-in
1176 source file: xlfio.c
1177 Common LISP compatible: yes
1178 supported on: all machines
1179
1180 SYNTAX
1181
1182 (make-string-input-stream <string> [ <start-pos> [ <end-pos> ] ] )
1183 <string> - a string expression
1184 <start-pos> - an optional numeric expression, default value
1185 is 0 (giving the first character of the string)
1186 <end-pos> - an optional numeric expression, default value
1187 is the length of the string
1188
1189 DESCRIPTION
1190
1191 The MAKE-STRING-INPUT-STREAM function creates an unnamed stream from
1192 the <string> expression. The stream can then be used as any other
1193 stream object. The optional <start-pos> expression specifies the
1194 starting offset of the <string> expression. A <start-pos> of 0 will
1195 start with the beginning of the <string>. The optional <end-pos>
1196 expression specifies the ending offset of the <string> expression. A
1197 <end-pos> of 4 will make the fourth character the last in the stream.
1198 If the function is successful, it returns the unnamed stream object.
1199 If the string is empty, an unnamed stream is still returned. Error
1200 conditions include <start-pos> and <end-pos> being out of bounds.
1201
1202 EXAMPLES
1203
1204 (make-string-input-stream "abcdefgh") ; returns #<Unnamed-Stream: #277e2>
1205 (read (make-string-input-stream ;
1206 "123456")) ; returns 123456
1207 (read (make-string-input-stream ;
1208 "123456" 1)) ; returns 23456
1209 (read (make-string-input-stream ;
1210 "123456" 1 3)) ; returns 23
1211 ;
1212 (read (make-string-input-stream ;
1213 "123" 0)) ; returns 123
1214 (read (make-string-input-stream ;
1215 "123" 0 3)) ; returns 123
1216 (read (make-string-input-stream ;
1217 "123" 2 1)) ; returns NIL
1218 (read (make-string-input-stream ;
1219 "123" 0 4)) ; error: string index out of
1220 ; bounds - 4
1221
1222
1223
1224 
1225 File: slisp, Node: make-string-output-stream, Next: make-symbol, Prev: make-string-input-stream, Up: Xlisp Language Reference
1226
1227 make-string-output-stream
1228 =========================
1229
1230 make-string-output-stream
1231 type: function (subr)
1232 location: built-in
1233 source file: xlfio.c
1234 Common LISP compatible: yes
1235 supported on: all machines
1236
1237 SYNTAX
1238
1239 (make-string-output-stream)
1240
1241 DESCRIPTION
1242
1243 The MAKE-STRING-OUTPUT-STREAM function creates and returns an unnamed
1244 output stream. The stream can then be used as any other stream object.
1245
1246 EXAMPLES
1247
1248 (make-string-output-stream) ; returns #<Unnamed-Stream: #2d9c0>
1249 (setq out (make-string-output-stream)) ; returns #<Unnamed-Stream: #2d95c>
1250 (format out "fee fi fo fum ") ; \
1251 (format out "I smell the blood of ") ; fill up output stream
1252 (format out "Elmer Fudd") ; /
1253 (get-output-stream-string out) ; returns
1254 ; "fee fi fo fum I smell
1255 ; the blood of Elmer Fudd"
1256 (format out "~%now what") ; add more to output stream
1257 (get-output-stream-string out) ; returns "\nnow what"
1258 (format out "hello") ; add more to output stream
1259 (read out) ; returns HELLO
1260
1261
1262
1263 
1264 File: slisp, Node: make-symbol, Next: makunbound, Prev: make-string-output-stream, Up: Xlisp Language Reference
1265
1266 make-symbol
1267 ===========
1268
1269 make-symbol
1270 type: function (subr)
1271 location: built-in
1272 source file: xlbfun.c
1273 Common LISP compatible: yes
1274 supported on: all machines
1275
1276 SYNTAX
1277
1278 (make-symbol <symbol-str> )
1279 <symbol-str> - a string expression
1280
1281 DESCRIPTION
1282
1283 The MAKE-SYMBOL function takes a string name - <symbol-str> and
1284 creates a new symbol. This symbol is temporary and is not interned
1285 (placed) into the symbol hash table *OBARRAY*. If the symbol already
1286 exists, no error or action is taken and the old values and property
1287 lists remain intact. The MAKE-SYMBOL function returns the symbol as
1288 its result.
1289
1290 EXAMPLES
1291
1292 (defun lookin (sym) ; create a function to
1293 (aref *obarray* ; look inside *OBARRAY*
1294 (hash sym (length *obarray*)))); and look for a specific
1295 ; symbol - returns a list
1296 ;
1297 (lookin "FEE") ; returns (CHAR-INT NTH ++)
1298 ; FEE symbol doesn't exist
1299 (MAKE-SYMBOL "FEE") ; returns FEE symbol
1300 (lookin "FEE") ; returns (CHAR-INT NTH ++)
1301 ; FEE still doesn't exist
1302 (intern "FEE") ; intern FEE symbol
1303 (lookin "FEE") ; returns (FEE CHAR-INT NTH ++)
1304 ; FEE does now exist
1305
1306 NOTE: When you MAKE-SYMBOL a symbol like "fingers", this is a lower
1307 case symbol. Note that this is different from doing a MAKE-SYMBOL on
1308 "FINGERS". "fingers" and "FINGERS" are two different symbols. Remember
1309 also that normal symbols created by XLISP are upper case names.
1310
1311
1312

brinkley@uw.edu
ViewVC Help
Powered by ViewVC 1.1.26