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

Contents of /skandha4/info/slisp-12

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Tue May 25 09:39:15 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: remove, Next: remove-if, Prev: rem, Up: Xlisp Language Reference
12
13 remove
14 ======
15
16 remove
17 type: function (subr)
18 location: built-in
19 source file: xllist.c
20 Common LISP compatible: similar
21 supported on: all machines
22
23 SYNTAX
24
25 (remove <expr> <list-expr> [ { :test | :test-not } <test> ] )
26 <expr> - the expression to remove - an atom or list
27 <list-expr> - the list to remove from
28 <test> - optional test function (default is EQL)
29
30 DESCRIPTION
31
32 REMOVE searches through <list-expr> for <expr>. If <expr> is found,
33 REMOVE returns the list with the <expr> deleted. All occurances of
34 <expr> are deleted. If <expr> is not found, then the <list-expr> is
35 returned unaltered. You may specify your own test with the :TEST and
36 :TEST-NOT keywords followed by the test you which to perform. Note that
37 this operation is non-destructive, it does not modify or affect
38 <list-expr> directly - it creates a modified copy.
39
40 EXAMPLES
41
42 (setq mylist '(a b c d it e f)) ; set up a list
43 (remove 'it mylist) ; returns (A B C D E F)
44 (print mylist) ; prints (A B C D IT E F)
45 ; note that MYLIST is not
46 ; affected
47 (setq mylist '(a b c b d b)) ; change list to include
48 ; duplicates
49 (remove 'b mylist) ; returns (A C D)
50 ;
51 (setq alist '( (a) (b) (it) (c))) ; set up another list
52 (remove '(it) alist) ; returns ((A) (B) (IT) (C))
53 ; the EQ test doesn't work
54 ; for lists
55 (remove '(it) alist :test 'equal) ; returns ((A) (B) (C))
56 ;
57 (setq slist '( "a" "b" "it" "c")) ; set up yet another list
58 (remove "it" slist) ; returns ("a" "b" "c")
59 (remove "it" slist :test-not 'equal) ; returns ("it") - REMOVE
60 ; takes away everything but IT
61
62 NOTE: The REMOVE function can work with a list or string as the
63 <expr>. However, the default EQL test does not work with lists or
64 strings, only symbols and numbers. To make this work, you need to use
65 the :TEST keyword along with EQUAL for <test>.
66
67 COMMON LISP COMPATIBILITY: XLISP does not support the :FROM-END,
68 :START, :END, :COUNT and :KEY keywords which Common LISP does.
69
70
71
72 
73 File: slisp, Node: remove-if, Next: remove-if-not, Prev: remove, Up: Xlisp Language Reference
74
75 remove-if
76 =========
77
78 remove-if
79 type: function (subr)
80 location: built-in
81 source file: xllist.c
82 Common LISP compatible: similar
83 supported on: all machines
84
85 SYNTAX
86
87 (remove-if <test> <list-expr> )
88 <test> - the test function to be performed
89 <list-expr> - the list to remove from
90
91 DESCRIPTION
92
93 REMOVE-IF searches through <list-expr> and removes any elements that
94 pass the <test>. Note that this operation is non-destructive, it does
95 not modify or affect <list-expr> directly - it creates a modified copy.
96
97 EXAMPLES
98
99 (setq mylist '(1 2 3 4 5 6 7 8)) ; set up a list
100 (remove-if 'oddp mylist) ; returns (2 4 6 8)
101 (remove-if 'evenp mylist) ; returns (1 3 5 7)
102 (print mylist) ; prints (1 2 3 4 5 6 7 8)
103 ; note that MYLIST is not
104 ; affected
105 ;
106 (setq mylist '(a nil b nil c)) ; set up a list
107 (remove-if 'null mylist) ; returns (A B C)
108
109 COMMON LISP COMPATIBILITY: XLISP does not support the :FROM-END,
110 :START, :END, :COUNT and :KEY keywords which Common LISP does.
111
112
113
114 
115 File: slisp, Node: remove-if-not, Next: remprop, Prev: remove-if, Up: Xlisp Language Reference
116
117 remove-if-not
118 =============
119
120 remove-if-not
121 type: function (subr)
122 location: built-in
123 source file: xllist.c
124 Common LISP compatible: similar
125 supported on: all machines
126
127 SYNTAX
128
129 (remove-if-not <test> <list-expr> )
130 <test> - the test function to be performed
131 <list-expr> - the list to remove from
132
133 DESCRIPTION
134
135 REMOVE-IF-NOT searches through <list-expr> and removes any elements
136 that fail the <test>. Note that this operation is non-destructive, it
137 does not modify or affect <list-expr> directly - it creates a modified
138 copy.
139
140 EXAMPLES
141
142 (setq mylist '(1 2 3 4 5 6 7 8)) ; set up a list
143 (remove-if-not 'oddp mylist) ; returns (1 3 5 7)
144 (remove-if-not 'evenp mylist) ; returns (2 4 6 8)
145 (print mylist) ; prints (1 2 3 4 5 6 7 8)
146 ; note that MYLIST is not
147 ; affected
148 ;
149 (setq mylist '(a nil b nil c)) ; set up a list
150 (remove-if-not 'null mylist) ; returns (NIL NIL)
151
152 COMMON LISP COMPATIBILITY: XLISP does not support the :FROM-END,
153 :START, :END, :COUNT and :KEY keywords which Common LISP does.
154
155
156
157 
158 File: slisp, Node: remprop, Next: rest, Prev: remove-if-not, Up: Xlisp Language Reference
159
160 remprop
161 =======
162
163 remprop
164 type: function (subr)
165 location: built-in
166 source file: xlbfun.c
167 Common LISP compatible: no
168 supported on: all machines
169
170 SYNTAX
171
172 (remprop <symbol> <property> )
173 <symbol> - the symbol with a property list
174 <property> - the property name being removed
175
176 DESCRIPTION
177
178 REMPROP removes the <property> from the <symbol>. The function
179 returns a NIL. If the <property> does not exist, there is no error
180 generated. The <symbol> must be an existing symbol. Property lists
181 are lists attached to any user defined variables. The lists are in the
182 form of (name1 val1 name2 val2 ....). Any number of properties may be
183 attached to a single variable.
184
185 EXAMPLES
186
187 (setq person 'bobby) ; create a var with a value
188 (putprop person 'boogie 'last-name) ; add a LAST-NAME property
189 (putprop person 'disc-jockey 'job) ; add a JOB property
190 (get person 'last-name) ; retrieve LAST-NAME - boogie
191 (get person 'job) ; retrieve JOB - disc-jockey
192 (get person 'height) ; non-existant - returns NIL
193 (remprop person 'job) ; remove JOB
194 (remprop person 'height) ; remove non-existant
195
196 COMMON LISP COMPATIBILITY: Common LISP does not have a REMPROP
197 function. It uses a SETF to achieve this functionality. Porting from
198 Common LISP to XLISP will work fine since XLISP supports the SETF
199 modifications of property lists and GET. Porting from XLISP to Common
200 LISP will require translating REMPROP into SETF forms.
201
202
203
204 
205 File: slisp, Node: rest, Next: &rest, Prev: remprop, Up: Xlisp Language Reference
206
207 rest
208 ====
209
210 rest
211 type: function (subr)
212 location: built-in
213 source file: xlinit.lsp
214 Common LISP compatible: yes
215 supported on: all machines
216
217 SYNTAX
218
219 (rest <expr> )
220 <expr> - a list or list expression
221
222 DESCRIPTION
223
224 REST returns the remainder of a list or list expression after first
225 element of the list is removed. If the list is NIL, NIL is returned.
226
227 EXAMPLES
228
229 (rest '(a b c)) ; returns (B C)
230 (rest '((a b) c d)) ; returns (C D)
231 (rest NIL) ; returns NIL
232 (rest 'a) ; error: bad argument type
233 (rest '(a)) ; returns NIL
234 ;
235 (setq sisters '(virginia vicki cindy)) ; set up variable SISTERS
236 (first sisters) ; returns VIRGINIA
237 (rest sisters) ; returns (VICKI CINDY)
238
239 NOTE: The REST function is set to the same code as CDR.
240
241
242
243 
244 File: slisp, Node: &rest, Next: restore, Prev: rest, Up: Xlisp Language Reference
245
246 &rest
247 =====
248
249 &rest
250 type: keyword
251 location: built-in
252 source file: xleval.c
253 Common LISP compatible: yes
254 supported on: all machines
255
256 SYNTAX
257
258 &rest [ <rest-arg> ]
259 <rest-arg> - rest argument symbol
260
261 DESCRIPTION
262
263 In XLISP, there are several times that you define a formal argument
264 list for a body of code (like DEFUN, DEFMACRO, :ANSWER and LAMBDA).
265 All of the formal arguments that are defined are required to appear in
266 the invocation of the defined function or operation. If there are any
267 &OPTIONAL arguments defined, they will be filled in order. If there is
268 a &REST argument defined, and all the required formal arguments and
269 &OPTIONAL arguments are filled, any and all further parameters will be
270 passed into the function via the <rarg> argument. There can be only one
271 <rest-arg> argument for &REST. If there are insufficient parameters for
272 any of the &OPTIONAL or &REST arguments, they will contain NIL. At the
273 end of the function or operation execution, these local symbols and
274 their values are are removed.
275
276 EXAMPLES
277
278 (defun foo ; define function FOO
279 (a b &optional c d &rest e) ; with some of each argument
280 (print a) (print b) ;
281 (print c) (print d) ; print out each
282 (print e)) ;
283 (foo) ; error: too few arguments
284 (foo 1) ; error: too few arguments
285 (foo 1 2) ; prints 1 2 NIL NIL NIL
286 (foo 1 2 3) ; prints 1 2 3 NIL NIL
287 (foo 1 2 3 4) ; prints 1 2 3 4 NIL
288 (foo 1 2 3 4 5) ; prints 1 2 3 4 (5)
289 (foo 1 2 3 4 5 6 7 8 9) ; prints 1 2 3 4 (5 6 7 8 9)
290 ;
291 ;
292 (defun my-add ; define function MY-ADD
293 (num1 &rest num-list &aux sum) ; with 1 arg, rest, 1 aux var
294 (setq sum num1) ; clear SUM
295 (dotimes (i (length num-list) ) ; loop through rest list
296 (setq sum (+ sum (car num-list))) ; add the number to sum
297 (setq num-list (cdr num-list))) ; and remove num from list
298 sum) ; return sum when finished
299 (my-add 1 2 3 4) ; returns 10
300 (my-add 5 5 5 5 5) ; returns 25
301
302
303
304 
305 File: slisp, Node: restore, Next: return, Prev: &rest, Up: Xlisp Language Reference
306
307 restore
308 =======
309
310 restore
311 type: function (subr)
312 location: built-in
313 source file: xldmem.c xlimage.c
314 Common LISP compatible: no
315 supported on: all machines
316
317 SYNTAX
318
319 (restore <file> )
320 <file> - a string or symbol for the name of the file
321
322 DESCRIPTION
323
324 The RESTORE function restores the previously saved XLISP workspace
325 (system state) from the specified file. The <file> may be a string or a
326 symbol. If the <file> does not include a '.wks' suffix, it will be
327 extended to be called <file>.wks. If successful, RESTORE will print a
328 message saying
329
330 [ returning to the top level ]
331
332 and will not return any value. If RESTORE fails, it will return
333 NIL. There can be several saved workspaces. These workspaces can be
334 restored as often as desired.
335
336 EXAMPLES
337
338 (defun myfoo (fee fi) ; create a function
339 (+ fee fi))
340 (setq myvar 5) ; set MYVAR to value 5
341 myvar ; returns 5
342 (save 'farp) ; save workspace in FARP.wks
343 ;
344 (setq myvar "garp") ; change MYVAR to "garp"
345 myvar ; returns "garp"
346 ;
347 (restore 'farp) ; restore workspace
348 myvar ; returns 5
349
350 FILE NAMES: In the PC and DOS world, all file names and extensions
351 ("FOO.BAT") are automatically made uppercase. In using XLISP, this
352 means you don't have to worry about whether the name is
353 "foo.bat", "FOO.BAT" or even "FoO.bAt" - they will all work.
354 However, in other file systems (UNIX in particular), uppercase and
355 lowercase do make a difference. So, in UNIX if you do a (open
356 'foo-file :direction :output), this will create a file named
357 "FOO-FILE" because XLISP uppercases its symbols. If you do a (open
358 "foo-file" :direction :output), this will create a file named
359 "foo-file" because UNIX doesn't uppercase its file names. Another case
360 is if you do (save 'world), this will create the file "WORLD.wks". So,
361 if you are having trouble with opening and accessing files, check to
362 make sure the file name is in the proper case.
363
364
365
366 
367 File: slisp, Node: return, Next: return-from, Prev: restore, Up: Xlisp Language Reference
368
369 return
370 ======
371
372 return
373 type: special form (fsubr)
374 location: built-in
375 source file: xlcont.c
376 Common LISP compatible: yes
377 supported on: all machines
378
379 SYNTAX
380
381 (return [ <expr> ] )
382 <expr> - an expression
383
384 DESCRIPTION
385
386 The RETURN special form allows the return of an arbitrary value at
387 arbitrary times within 'block' constructs (DO, DO*, DOLIST, DOTIMES,
388 LOOP, PROG and PROG*). The <expr> will be returned by the outer 'block'
389 construct. A NIL will be returned by the outer 'block' construct if
390 there is no <expr> specified. If RETURN is used without being within a
391 valid 'block' construct, an error is generated: "error: no target for
392 RETURN".
393
394 EXAMPLES
395
396 (prog (i) ; PROG form
397 (print i) (RETURN "foo") (print j)) ; prints NIL returns "foo"
398 ;
399 (dotimes (i 10) ;
400 (if (eql i 5) (RETURN 20) ;
401 (princ i))) ; prints 01234 returns 20
402 ;
403 (prog1 (print "hi") (RETURN "foo")) ; prints "hi"
404 ; error: no target for RETURN
405 ;
406 (return 9) ; error: no target for RETURN
407
408
409
410 
411 File: slisp, Node: return-from, Next: reverse, Prev: return, Up: Xlisp Language Reference
412
413 return-from
414 ===========
415
416 return-from
417 type: special form (fsubr)
418 location: built-in
419 source file: xlcont.c
420 Common LISP compatible: yes
421 supported on: all machines
422
423 SYNTAX
424
425 (return-from <name> [ <expr> ] )
426 <name> - an unevaluated symbol for the block name
427 <expr> - an expression
428
429 DESCRIPTION
430
431 The RETURN-FROM special form allows the return of an arbitrary value
432 at arbitrary times within a 'named-block' construct (BLOCK) of the
433 specified <name>. The <expr> will be returned by the BLOCK construct.
434 A NIL will be returned by the BLOCK construct if there is no <expr>
435 specified. If RETURN-FROM is used without being within a valid BLOCK
436 construct, an error is generated: "error: no target for RETURN".
437
438 EXAMPLES
439
440 (block out ; outer BLOCK
441 (print "outer") ;
442 (block in ; inner BLOCK
443 (print "inner") ;
444 (return-from out "all done") ;
445 (print "won't get here") ;
446 ) ;
447 ) ; prints "outer"
448 ; prints "inner"
449 ; returns "all done"
450 ;
451 (return-from nobody 9) ; error: no target for RETURN
452
453
454
455 
456 File: slisp, Node: reverse, Next: room, Prev: return-from, Up: Xlisp Language Reference
457
458 reverse
459 =======
460
461 reverse
462 type: function (subr)
463 location: built-in
464 source file: xllist.c
465 Common LISP compatible: yes
466 supported on: all machines
467
468 SYNTAX
469
470 (reverse <list-expr> )
471 <list-expr> - a list or list expression
472
473 DESCRIPTION
474
475 The REVERSE function reverses the <list-expr>. The reversed list is
476 the returned value. The reversal process only occurs on the
477 'top-level' of the <list-expr>. If there are nested sub-lists, these
478 are left intact.
479
480 EXAMPLES
481
482 (reverse NIL) ; returns NIL
483 (reverse 'a) ; error: bad argument type
484 (reverse '(a)) ; returns (A)
485 (reverse '(a b c)) ; returns (C B A)
486 (reverse '((a b) (c d) (e f))) ; returns ((E F) (C D) (A B))
487 (reverse (list (+ 1 2) (+ 3 4))) ; returns (7 3)
488
489
490
491 
492 File: slisp, Node: room, Next: rplaca, Prev: reverse, Up: Xlisp Language Reference
493
494 room
495 ====
496
497 room
498 type: function (subr)
499 location: built-in
500 source file: xldmem.c
501 Common LISP compatible: yes
502 supported on: all machines
503
504 SYNTAX
505
506 (room [ <info> ] )
507 <info> - an optional, unused expression
508
509 DESCRIPTION
510
511 The ROOM function prints the current memory statistics to
512 *STANDARD-OUTPUT*. NIL is always returned. The message shows the
513 statistics for total NODES, current FREE NODES, current number of
514 allocated memory SEGMENTS, node size of the ALLOCATEd memory segments,
515 TOTAL memory in bytes and total number of garbage COLLECTIONS that have
516 occured since this session of XLISP started.
517
518 EXAMPLES
519
520 (room) ; prints Nodes: 4000
521 ; Free nodes: 1723
522 ; Segments: 4
523 ; Allocate: 1000
524 ; Total: 52566
525 ; Collections: 8
526 ; returns NIL
527
528 COMMON LISP COMPATIBILITY: In Common LISP, the <info> argument
529 controls the amount of information that is printed.
530
531 COMMON LISP COMPATIBILITY: The form of and information provided by
532 the ROOM output is implementation dependent. For portability, you
533 should not count on this information or form.
534
535
536
537 
538 File: slisp, Node: rplaca, Next: rplacd, Prev: room, Up: Xlisp Language Reference
539
540 rplaca
541 ======
542
543 rplaca
544 type: function (subr)
545 location: built-in
546 source file: xllist.c
547 Common LISP compatible: yes
548 supported on: all machines
549
550 SYNTAX
551
552 (rplaca <list> <expr> )
553 <list> - the list to DESTRUCTIVELY modify
554 <expr> - the expression to replace CAR of <list>
555
556 DESCRIPTION
557
558 RPLACA destructively modifies the CAR of <list> and replaces it with
559 the <expr>. The destructive aspect of this operation means that the
560 actual symbol value is used in the list-modifying operations - not a
561 copy. <list> must evaluate to a valid list. An atom or NIL for <list>
562 will result in an error.
563
564 EXAMPLES
565
566 (setq a '(1 2 3)) ; make A with value (1 2 3)
567 (setq b '(1 2 3)) ; make B with value (1 2 3)
568 (setq c a) ; make C point to A's value
569 (rplaca a 'new) ; returns (NEW 2 3)
570 (print a) ; prints (NEW 2 3)
571 ; NOTE THAT A IS MODIFIED!
572 (print b) ; prints (1 2 3)
573 ; note that B is not modified
574 (print c) ; prints (NEW 2 3)
575 ; NOTE THAT C IS MODIFIED TOO!
576 ;
577 (setq a '(1 2 3)) ; reset A to value (1 2 3)
578 (rplaca a '(the sub list)) ; returns ((THE SUB LIST) 2 3)
579 (rplaca '(1 2 3) 'more) ; returns (MORE 2 3)
580 ;
581 (rplaca 'a 'b) ; error: bad argument type
582 (rplaca NIL 'b) ; error: bad argument type
583
584
585
586 
587 File: slisp, Node: rplacd, Next: save, Prev: rplaca, Up: Xlisp Language Reference
588
589 rplacd
590 ======
591
592 rplacd
593 type: function (subr)
594 location: built-in
595 source file: xllist.c
596 Common LISP compatible: yes
597 supported on: all machines
598
599 SYNTAX
600
601 (rplacd <list> <expr> )
602 <list> - the list to DESTRUCTIVELY modify
603 <expr> - the expression to replace the CDR of <list>
604
605 DESCRIPTION
606
607 RPLACD destructively modifies the CDR of <list> and replaces it with
608 the <expr>. The destructive aspect of this operation means that the
609 actual symbol value is used in the list-modifying operations - not a
610 copy. <list> must evaluate to a valid list. An atom or NIL for <list>
611 will result in an error.
612
613 EXAMPLES
614
615 (setq a '(1 2 3)) ; set up A with (1 2 3)
616 (rplacd a 'new) ; returns (1 . NEW)
617 (print a) ; prints (1 . NEW)
618 ; NOTE THAT A IS MODIFIED!
619 ;
620 (rplacd a '(a new list)) ; returns (1 A NEW LIST)
621 (rplacd '(1 2 3) '(more)) ; returns (1 MORE)
622 (rplacd 'a 'b) ; error: bad argument type
623 (rplacd NIL 'b) ; error: bad argument type
624
625
626
627 
628 File: slisp, Node: save, Next: savefun, Prev: rplacd, Up: Xlisp Language Reference
629
630 save
631 ====
632
633 save
634 type: function (subr)
635 location: built-in
636 source file: xldmem.c xlimage.c
637 Common LISP compatible: no
638 supported on: all machines
639
640 SYNTAX
641
642 (save <file> )
643 <file> - a string or symbol for the name of the file
644
645 DESCRIPTION
646
647 The SAVE function saves the current XLISP workspace (system state) to
648 the specified file. The <file> may be a string or a symbol. If the
649 <file> does not include a '.wks' suffix, it will be extended to be
650 called <file>.wks. The function returns T if the workspace was properly
651 created and saved, NIL is returned otherwise. There can be several
652 saved workspaces. These workspaces can be restored as often as desired.
653
654 EXAMPLES
655
656 (defun myfoo (fee fi) ; create a function
657 (+ fee fi))
658 (setq myvar 5) ; set MYVAR to value 5
659 myvar ; returns 5
660 (save 'farp) ; save workspace in FARP.wks
661 ;
662 (setq myvar "garp") ; change MYVAR to "garp"
663 myvar ; returns "garp"
664 ;
665 (restore 'farp) ; restore workspace
666 myvar ; returns 5
667
668 BUG: The SAVE function generates a system error if the <file>
669 being created already exists. This <file> will be modified and will
670 not be restorable after restarting XLISP.
671
672 NOTE: The saved workspace size is implementation dependent, but can
673 be fairly large.
674
675 FILE NAMES: In the PC and DOS world, all file names and extensions
676 ("FOO.BAT") are automatically made uppercase. In using XLISP, this
677 means you don't have to worry about whether the name is "foo.bat",
678 "FOO.BAT" or even "FoO.bAt" - they will all work. However, in other
679 file systems (UNIX in particular), uppercase and lowercase do make a
680 difference. So, in UNIX if you do a (open 'foo-file :direction
681 :output), this will create a file named "FOO-FILE" because XLISP
682 uppercases its symbols. If you do a (open "foo-file" :direction
683 :output), this will create a file named "foo-file" because UNIX doesn't
684 uppercase its file names. Another case is if you do (save 'world),
685 this will create the file "WORLD.wks". So, if you are having trouble
686 with opening and accessing files, check to make sure the file name is
687 in the proper case.
688
689 COMMON LISP COMPATIBILITY: The SAVE function is similar in use to
690 the SAVE-WORLD function in Common LISP. The primarily difference is
691 that SAVE-WORLD allows you to restart everything since it creates an
692 executable file. The SAVE function requires you to start XLISP up
693 first and then do a RESTORE. Depending on the operating system that
694 you are using, it is possible to write a SAVE-WORLD equivalent using
695 SAVE, RESTORE and SYSTEM functions.
696
697
698
699 
700 File: slisp, Node: savefun, Next: second, Prev: save, Up: Xlisp Language Reference
701
702 savefun
703 =======
704
705 savefun
706 type: defined macro (closure)
707 location: extension
708 source file: init.lsp
709 Common LISP compatible: no
710 supported on: all machines
711
712 SYNTAX
713
714 (savefun <function> )
715 <function> - the name of the function or macro to be saved
716
717 DESCRIPTION
718
719 The SAVEFUN macro saves the specified function or macro to a file.
720 The file will be called <function>.lsp. The macro returns the file name
721 that was created. An error will occur if the <function> parameter is
722 not a function or macro.
723
724 EXAMPLES
725
726 (defun myfoo (fee fi) ; create a function
727 (+ fee fi))
728 (savefun myfoo) ; saves MYFOO to "MYFOO.lsp"
729 (savefun savefun) ; saves SAVEFUN to "SAVEFUN.lsp"
730 (savefun 'a) ; error: bad argument type
731
732 NOTE: The SAVEFUN macro is defined in the INIT.LSP file. If SAVEFUN
733 does not exist in your XLISP system, you might be having a problem with
734 INIT.LSP. Before you start XLISP, look in the directory you are
735 currently in, and check to see if there is an INIT.LSP. Another thing
736 to try is to put a PRINT message in the INIT.LSP file and make sure
737 that it is printed out when XLISP starts running.
738
739
740
741 
742 File: slisp, Node: second, Next: self, Prev: savefun, Up: Xlisp Language Reference
743
744 second
745 ======
746
747 second
748 type: function (subr)
749 location: built-in
750 source file: xlinit.c
751 Common LISP compatible: yes
752 supported on: all machines
753
754 SYNTAX
755
756 (second <expr> )
757 <expr> - a list or list expression
758
759 DESCRIPTION
760
761 SECOND returns the second element of a list or list expression. If
762 the list is NIL, NIL is returned.
763
764 EXAMPLES
765
766 (second '(1 2 3)) ; returns 2
767 (second NIL) ; returns NIL
768 ;
769 (setq carol '(a b c)) ; set up variable CAROL
770 (first carol) ; returns A
771 (second carol) ; returns B
772 (rest carol) ; returns (B C)
773 ;
774 (setq children '(amanda ben)) ; set up variable CHILDREN
775 (second children) ; returns BEN
776
777 NOTE: This function is set to the same code as CADR.
778
779
780
781 
782 File: slisp, Node: self, Next: send, Prev: second, Up: Xlisp Language Reference
783
784 self
785 ====
786
787 self
788 type: symbol
789 location: built-in
790 source file: xlobj.c
791 Common LISP compatible: no
792 supported on: all machines
793
794 SYNTAX
795
796 self
797
798 DESCRIPTION
799
800 SELF evaluates to the current object when used within a message
801 context.
802
803 EXAMPLES
804
805 (setq my-class ; create MY-CLASS with STATE
806 (send class :new '(state))) ;
807 (send my-class :answer :isnew '() ; set up initialization
808 '((setq state nil) SELF)) ; returning SELF
809 (send my-class :answer :set-it '(value) ; create :SET-IT message
810 '((setq state value))) ;
811 (setq my-obj (send my-class :new)) ; create MY-OBJ of MY-CLASS
812 (send my-obj :set-it 5) ; STATE is set to 5
813
814 CONTEXT: SELF does not exist except within the context of a
815 method and it's execution.
816
817 NOTE: In the previous example, there is a SELF in the line that
818 creates the :SET-IT message. What this does is to return the object as
819 the last operation when you do an :ISNEW.
820
821
822
823 
824 File: slisp, Node: send, Next: send-super, Prev: self, Up: Xlisp Language Reference
825
826 send
827 ====
828
829 send
830 type: function (subr)
831 location: built-in
832 source file: xlobj.c
833 Common LISP compatible: no
834 supported on: all machines
835
836 SYNTAX
837
838 (send <object> <message> [<args>] )
839 <object> - an object
840 <message> - message selector for object
841 <arg> - parameter sent to object method
842
843 DESCRIPTION
844
845 The SEND function is the mechanism used to send a <message> to an
846 <object>. The <message> is the message selector symbol that is used to
847 select a particular action (method) from the object.
848
849 EXAMPLES
850
851 (setq myclass (send class :new '(var))) ; create MYCLASS with VAR
852 (send myclass :answer :isnew '() ; set up initialization
853 '((setq var nil) self))
854 (send myclass :answer :set-it '(value) ; create :SET-IT message
855 '((setq var value)))
856 (setq my-obj (send myclass :new)) ; create MY-OBJ of MYCLASS
857 (send my-obj :set-it 5) ; VAR is set to 5
858
859 BUILT-IN METHODS: The built in methods in XLISP include:
860
861 <message> operation
862 -------------------------------------------------------
863 :ANSWER Add a method to an object.
864 :CLASS Return the object's class.
865 :ISNEW Run initialization code on object.
866 :NEW Create a new object (instance or class).
867 :SHOW Show the internal state of the object.
868
869 MESSAGE STRUCTURE: The normal XLISP convention for a <message> is to
870 have a valid symbol preceeded by a colon like :ISNEW or :MY-MESSAGE.
871 However, it is possible to define a <message> that is a symbol without
872 a colon, but this makes the code less readable.
873
874
875
876 
877 File: slisp, Node: send-super, Next: ;sescape, Prev: send, Up: Xlisp Language Reference
878
879 send-super
880 ==========
881
882 send-super
883 type: function (subr)
884 location: built-in
885 source file: xlobj.c
886 Common LISP compatible: no
887 supported on: all machines
888
889 SYNTAX
890
891 (send-super <message> [<args>])
892 <message> - the message selector
893 <args> - the optional message arguments
894
895 DESCRIPTION
896
897 The SEND-SUPER function sends the specified arguments <args> to the
898 <message> specified method of the superclass. It is necessary for
899 SEND-SUPER to be executed from within a method being performed on an
900 object. It will return the result of sending the message. If
901 SEND-SUPER is performed outside of a method an error "error: not in a
902 method" will result.
903
904 EXAMPLES
905
906 (setq a-class (send class :new '())) ; create A-CLASS
907 (send a-class :answer :show '() ; set up special SHOW method
908 '((print "nobody here") self)) ;
909 (setq an-obj (send a-class :new)) ; create AN-OBJ of A-CLASS
910 (send an-obj :show) ; prints "nobody here"
911 (send a-class :answer :myshow '() ; set up MYSHOW method which
912 '((send-super :show ))) ; calls :SHOW in superclass
913 (send an-obj :myshow) ; prints Object is ............
914
915
916
917 
918 File: slisp, Node: ;sescape, Next: set, Prev: send-super, Up: Xlisp Language Reference
919
920 :sescape
921 ========
922
923 :sescape
924 type: keyword
925 location: built-in
926 source file: xlread.c
927 Common LISP compatible: no
928 supported on: all machines
929
930 SYNTAX
931
932 :sescape
933
934 DESCRIPTION
935
936 :SESCAPE is an entry that is used in the *READTABLE*. *READTABLE*
937 is a system variable that contains XLISP's data structures relating to
938 the processing of characters from the user (or files) and read-macro
939 expansions. The existance of the :SESCAPE keyword means that the
940 specified character is to be used as a single escape character. The
941 system defines that the the vertical bar character \ is the only defined
942 :SESCAPE character.
943
944 EXAMPLES
945
946 (defun look-at (table) ; define a function to
947 (dotimes (ch 127) ; look in a table
948 (prog ( (entry (aref table ch)) ) ; and print out any
949 (case entry ; entries with a function
950 (:SESCAPE ;
951 (princ (int-char ch))) ;
952 (T NIL)))) ;
953 (terpri)) ;
954 (look-at *readtable*) ; prints \
955
956 CAUTION: If you experiment with *READTABLE*, it is useful to save
957 the old value in a variable, so that you can restore the system state.
958
959
960
961 
962 File: slisp, Node: set, Next: setf, Prev: ;sescape, Up: Xlisp Language Reference
963
964 set
965 ===
966
967 set
968 type: function (subr)
969 location: built-in
970 source file: xlbfun.c
971 Common LISP compatible: yes
972 supported on: all machines
973
974 SYNTAX
975
976 (set <symbol> <expr> )
977 <symbol> - expression that evaluates to a symbol name
978 (if expression is quoted, no evaluation occurs)
979 <expr> - an expression - which will be the new value
980
981 DESCRIPTION
982
983 SET evaluates <symbol> and sets <expr> as it's value. If the
984 <symbol> value is quoted (via the QUOTE special form or read-macro
985 expansion), the <symbol> is not evaluated. SET returns the value from
986 <expr> as it's result.
987
988 EXAMPLES
989
990 (set 'a 2) ; sets symbol A to value 2
991 (set 'value a) ; sets symbol VALUE to value 2
992 (print value) ; show the value - prints 2
993 (set 'name 'myvar) ; set symbol NAME to value MYVAR
994 (set name 12345) ; set symbol which is the value
995 ; of NAME (MYVAR) to 12345
996 (print name) ; prints MYVAR
997 (print myvar) ; prints 12345
998 ;
999 (set notsymbol 1) ; error: unbound variable
1000 (set name notvalue) ; error: unbound variable
1001
1002
1003
1004 
1005 File: slisp, Node: setf, Next: set-macro-character, Prev: set, Up: Xlisp Language Reference
1006
1007 setf
1008 ====
1009
1010 setf
1011 type: special form (fsubr)
1012 location: built-in
1013 source file: xlcont.c
1014 Common LISP compatible: yes
1015 supported on: all machines
1016
1017 SYNTAX
1018
1019 (setf [ <place1> <expr1> ... ] )
1020 <placeN> - a field specifier which may be one of:
1021 <symbol> (car <expr> )
1022 (cdr <expr> ) (nth <n> <expr> )
1023 (aref <expr> <n> ) (get <symb> <property> )
1024 (symbol-value <symb> ) (symbol-plist <symb> )
1025 <exprN> - an expression - which will be the new value
1026
1027 DESCRIPTION
1028
1029 SETF evaluates the field <placeN> and sets <exprN> as it's value.
1030 This is a generalized tool that allows you to set the value of the
1031 various data types of the system. SETF returns the value from <exprN>
1032 as it's result. The specific action of SETF depends on the <placeN>
1033 field.
1034
1035 EXAMPLES
1036
1037 ; SETF SYMBOL
1038 (setf a 123) ; set a symbol A to value 123
1039 ;
1040 ; SETF SYMBOL-VALUE
1041 (setq x 'y) ; make symbol X with value Y
1042 (setf (symbol-value x) 'z) ; set symbol that X contains (Y)
1043 ; to value Z
1044 ;
1045 ; SETF LIST ELEMENTS
1046 (setq mylist '(a b c d)) ; MYLIST with value (A B C D)
1047 (setf (car mylist) 'x) ; change CAR of MYLIST to X
1048 ; MYLIST now is (X B C D)
1049 (setf (cdr mylist) '(y z da-end)) ; change CDR of MYLIST to
1050 ; (Y Z DA-END) so that
1051 ; MYLIST now is (X Y Z DA-END)
1052 (setf (nth 3 mylist) 'here-i-am) ; change 3rd of MYLIST to
1053 ; HERE-I-AM so that MYLIST
1054 ; now is (X Y Z HERE-I-AM)
1055 ;
1056 ; SETF AREF
1057 (setq myarray (make-array 5)) ; make MYARRAY
1058 (aref myarray 2) ; get value of element 2 = NIL
1059 (setf (aref myarray 2) 'new-value) ; set value of element 2 to
1060 ; value NEW-VALUE
1061 (print myarray) ; prints
1062 ; #(NIL NIL NEW-VALUE NIL NIL)
1063 ;
1064 ; SETF PROPERTIES
1065 (setq person 'joe-bob) ; make PERSON with value JOE-BOB
1066 (putprop person 'critic 'profession) ; set PROFESSION property to
1067 ; value CRITIC
1068 (setf (get person 'profession) ; change PROFESSION to value
1069 'texas-critic) ; TEXAS-CRITIC
1070 (setf (get person 'home) 'texas) ; add property HOME with
1071 ; value TEXAS
1072 (symbol-plist person) ; returns property list:
1073 ; (HOME TEXAS
1074 ; PROFESSION TEXAS-CRITIC)
1075 (setf (symbol-plist person) ; change the property list
1076 '(home on-the-range ;
1077 profession movie-critic)) ;
1078 (get person 'profession) ; now returns MOVIE-CRITIC
1079 (get person 'home) ; now returns ON-THE-RANGE
1080
1081 OPERATIONS:
1082
1083 <placeN> SETF action
1084 -------------------------------------------------------------------
1085 <symbol> Sets the value of <symbol> to the value
1086 of <exprN>. This is equivalent to a
1087 (SETQ <symbol> <exprN> ).
1088
1089 (car <expr> ) Sets the first element of the <expr>
1090 list to <exprN>. <expr> must be a list.
1091 This is equivalent to a (RPLACA <expr>
1092 <exprN> ) except that SETF will return
1093 <exprN> as the value. (cdr <expr> )
1094 Sets the tail of the <expr> list to
1095 <exprN>. <expr> must be a list. This
1096 is equivalent to a (RPLACD <expr>
1097 <exprN> ) except that SETF will return
1098 <exprN> as the value.
1099
1100 (nth <n> <expr> ) Sets the <n>th element of the <expr>
1101 list to <exprN>. <expr> must be a list.
1102 This allows you to set an arbitrary
1103 element of a list to an arbitrary value.
1104 Note that the list is numbered from the
1105 0th element (0, 1, 2, 3, ...).
1106
1107 (aref <expr> <n> ) Sets the <n>th element of the <expr>
1108 array to <exprN>. <expr> must be an
1109 array. This allows you to set an
1110 arbitrary element of an array to an
1111 arbitrary value. Note that the list is
1112 numbered from the 0th element (0, 1, 2,
1113 3, ...). Note also that this is the
1114 intended way to set the value of an
1115 array element.
1116
1117 (get <sym> <prop> ) Sets the <prop> of <sym> to the value
1118 <exprN>. If <sym> does not have the
1119 <prop>, one will be created. This is
1120 equivalent to (PUTPROP <sym> <exprN>
1121 <prop> ).
1122
1123 (symbol-value <symbol>) Sets the symbol's value to contain
1124 <exprN>. <symbol> is an expression that
1125 must evaluate to a valid symbol - it
1126 doesn't have to exist before the SETF,
1127 it just has to be a valid symbol. This
1128 is equivalent to (SET <symbol> <exprN>
1129 ).
1130
1131 (symbol-plist <symbol>) Sets the property list of <symbol> to
1132 <exprN>. This allows you to change (or
1133 destroy) the entire property list of a
1134 <symbol> at one time.
1135
1136
1137
1138 
1139 File: slisp, Node: set-macro-character, Next: setq, Prev: setf, Up: Xlisp Language Reference
1140
1141 set-macro-character
1142 ===================
1143
1144 set-macro-character
1145 type: defined function (closure)
1146 location: extension
1147 source file: init.lsp
1148 Common LISP compatible: related
1149 supported on: all machines
1150
1151 SYNTAX
1152
1153 (set-macro-character <char-num> <function> [ <termflag> ] )
1154 <char-num> - an integer expression
1155 <function> - a function definition
1156 <termflag> - an expression - NIL or non-NIL
1157
1158 DESCRIPTION
1159
1160 The SET-MACRO-CHARACTER function installs the code that will be
1161 executed when the specified character <char-num> is encountered by the
1162 XLISP reader. The <function> is placed in the *READTABLE* system
1163 variable which contains the reader table array. The table is 128
1164 entries (0..127) for each of the 7-bit ASCII characters that XLISP can
1165 read. Each entry in the table must be one of NIL, :CONSTITUENT,
1166 :SESCAPE, :MESCAPE, :WHITE-SPACE, a :TMACRO dotted pair or a :NMACRO
1167 dotted pair. The SET-MACRO-CHARACTER function only allows you to put
1168 in a terminating read-macro function (:TMACRO) or a non-terminating
1169 read-macro-function (:NMACRO). If the <termflag> is present and
1170 non-NIL, then the <function> will be put in *READTABLE* as a :TMACRO
1171 entry. If <termflag> is not present or NIL, then <function> will be
1172 put in *READTABLE* as a :NMACRO entry. The <function> can be a
1173 built-in read-macro function or a user defined defun symbol or a lambda
1174 expression. The <function> takes two parameters, an input stream
1175 specification, and an integer that is the character value. The
1176 <function> should return NIL if the character is 'white-space' or a
1177 value CONSed with NIL to return the value. The function
1178 SET-MACRO-CHARACTER always returns T.
1179
1180 EXAMPLES
1181
1182 (print "hi") % comment ; prints "hi" and gives
1183 ; error: unbound variable - %
1184 ; because percent is viewed
1185 ; as a variable
1186 ;
1187 (setq semi (get-macro-character #\;)) ; get semi-colon code
1188 ;
1189 (SET-MACRO-CHARACTER #\% semi T) ; set % to work as a comment
1190 ;
1191 (print "hi") % comment ; prints "hi" and no error
1192 ; because % is now a comment
1193 ; character in *READTABLE*
1194
1195 NOTE: In the normal XLISP system the following characters have code
1196 associated with them in the *READTABLE*:
1197
1198 " # ' ( ) , ; `
1199
1200 NOTE: The functions GET-MACRO-CHARACTER and SET-MACRO-CHARACTER are
1201 created in the INIT.LSP file. If they do not exist in your XLISP
1202 system, you might be having a problem with INIT.LSP. Before you start
1203 XLISP, look in the directory you are currently in, and check to see if
1204 there is an INIT.LSP.
1205
1206 COMMON LISP COMPATIBILITY: The SET-MACRO-CHARACTER function is
1207 somewhat related to the Common LISP SET-DISPATCH-MACRO-CHARACTER
1208 function.
1209
1210
1211
1212 
1213 File: slisp, Node: setq, Next: ;show, Prev: set-macro-character, Up: Xlisp Language Reference
1214
1215 setq
1216 ====
1217
1218 setq
1219 type: special form (fsubr)
1220 location: built-in
1221 source file: xlcont.c
1222 Common LISP compatible: yes
1223 supported on: all machines
1224
1225 SYNTAX
1226
1227 (setq [ <symbol1> <expr1> ] ... )
1228 <symbolN> - un-evaluated symbol
1229 <exprN> - value for <symbolN>
1230
1231 DESCRIPTION
1232
1233 SETQ sets <expr> as the value of <symbol>. SETQ returns the value
1234 from <expr> as it's result.
1235
1236 EXAMPLES
1237
1238 (setq a 1) ; symbol A gets value 1
1239 (setq b '(a b c)) ; symbol B gets value (A B C)
1240 (setq mynum (+ 3 4)) ; symbol MYNUM gets value 7
1241
1242
1243
1244 
1245 File: slisp, Node: ;show, Next: sin, Prev: setq, Up: Xlisp Language Reference
1246
1247 :show
1248 =====
1249
1250 :show
1251 type: message selector
1252 location: built-in
1253 source file: xlobj.c
1254 Common LISP compatible: no
1255 supported on: all machines
1256
1257 SYNTAX
1258
1259 (send <object> :show)
1260 <object> - an existing object
1261
1262 DESCRIPTION
1263
1264 The :SHOW message selector attempts to find the 'show' method in the
1265 specified <object>'s class. Since the :SHOW message selector is
1266 built-in in the root class (CLASS), this is always a valid message
1267 selector. The object must already exist.
1268
1269 EXAMPLES
1270
1271 (setq my-class ; create MY-CLASS with STATE
1272 (send class :new '(state))) ;
1273 (send my-class :answer :isnew '() ; set up initialization
1274 '((setq state nil) self))
1275 (send my-class :answer :set-it '(value) ; create :SET-IT message
1276 '((setq state value)))
1277 (setq my-obj (send my-class :new)) ; create MY-OBJ of MY-CLASS
1278 (send my-obj :show) ; returns object state including
1279 ; STATE = NIL
1280 (send my-obj :set-it 5) ; STATE is set to 5
1281 (send new-obj :show) ; error: unbound variable
1282
1283
1284
1285 
1286 File: slisp, Node: sin, Next: sort, Prev: ;show, Up: Xlisp Language Reference
1287
1288 sin
1289 ===
1290
1291 sin
1292 type: function (subr)
1293 location: built-in
1294 source file: xlmath.c
1295 Common LISP compatible: similar
1296 supported on: all machines
1297
1298 SYNTAX
1299
1300 (sin <expr> )
1301 <expr> - floating point number/expression
1302
1303 DESCRIPTION
1304
1305 The SIN function returns the sine of the <expr>. The <expr> is in
1306 radians.
1307
1308 EXAMPLES
1309
1310 (sin 0.0) ; returns 0
1311 (sin .5) ; returns 0.479426
1312 (sin 1.0) ; returns 0.841471
1313 (sin (/ 3.14159 2)) ; returns 1
1314 (sin 3.14159) ; returns 2.65359e-06
1315 (sin 0) ; error: bad integer operation
1316 (sin 1.) ; error: bad integer operation
1317
1318 COMMON LISP COMPATIBILITY: Common LISP allows for integer numbers,
1319 which XLISP does not support for SIN.
1320
1321
1322

brinkley@uw.edu
ViewVC Help
Powered by ViewVC 1.1.26