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

Contents of /skandha4/info/slisp-8

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Tue May 25 09:39:21 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: expt, Next: fboundp, Prev: expand, Up: Xlisp Language Reference
12
13 expt
14 ====
15
16 expt
17 type: function (subr)
18 location: built-in
19 source file: xlmath.c
20 Common LISP compatible: yes
21 supported on: all machines
22
23 SYNTAX
24
25 (expt <expr> [ <power> ... ] )
26 <expr> - floating point number/expression
27 <power> - integer or floating point number/expression
28
29 DESCRIPTION
30
31 The EXPT function raises the <expr> to the specified <power> and
32 returns the result. If there is no <power> specified, the <expr> is
33 returned. If there are multiple <power>'s, they will be applied
34 sequentially to <expr>.
35
36 EXAMPLES
37
38 (expt 2.0 2) ; returns 4
39 (expt 2.0 10) ; returns 1024
40 (expt 2 2) ; error: bad integer operation
41 (expt 99.9) ; returns 99.9
42 (expt 2.0 2.0 2.0) ; returns 16
43
44 NOTE: EXPT with a large values like (expt 999.9 999.9) causes an
45 incorrect value to be generated, with no error. The returned value
46 will be a very large floating point number near the computer's limit
47 (something like 1.79000e+308).
48
49
50
51 
52 File: slisp, Node: fboundp, Next: first, Prev: expt, Up: Xlisp Language Reference
53
54 fboundp
55 =======
56
57 fboundp
58 type: predicate function (subr)
59 location: built-in
60 source file: xlbfun.c
61 Common LISP compatible: yes
62 supported on: all machines
63
64 SYNTAX
65
66 (fboundp <symbol> )
67 <symbol> - the symbol expression to check for a value
68
69 DESCRIPTION
70
71 The FBOUNDP predicate checks to see if <symbol> is a symbol with a
72 function definition (closure) bound to it. T is returned if <symbol>
73 has a function value, NIL is returned otherwise. Note that <symbol> is
74 a symbol expression - it is evaluated and the resulting expression is
75 the one that is checked.
76
77 EXAMPLES
78
79 (defun foo (x) (print x)) ; set up function FOO
80 (fboundp 'foo) ; returns T - value is closure
81 (fboundp 'defvar) ; returns T - value is closure
82 (fboundp 'car) ; returns T - value is closure
83
84 (setq myvar 'goo) ; set up MYVAR to have value GOO
85 (FBOUNDP myvar) ; returns NIL - because GOO has
86 ; no value yet
87 (defmacro goo () (print "hi")) ; define GOO macro
88 (FBOUNDP myvar) ; returns T
89
90 (fboundp 'a) ; returns NIL
91 (fboundp '1) ; error: bad argument type - 1
92 (fboundp "hi") ; error: bad argument type - "hi"
93
94
95
96 
97 File: slisp, Node: first, Next: flatc, Prev: fboundp, Up: Xlisp Language Reference
98
99 first
100 =====
101
102 first
103 type: function (subr)
104 location: built-in
105 source file: xlinit.c
106 Common LISP compatible: yes
107 supported on: all machines
108
109 SYNTAX
110
111 (first <expr> )
112 <expr> - a list or list expression
113
114 DESCRIPTION
115
116 FIRST returns the first element of the expression. If the first
117 expression is itself a list, then the sublist is returned. If the list
118 is NIL, NIL is returned.
119
120 EXAMPLES
121
122 (first '(a b c)) ; returns A
123 (first '((a b) c d)) ; returns (A B)
124 (first NIL) ; returns NIL
125 (first 'a) ; error: bad argument type
126 (setq children '(amanda ben)) ; set up variable CHILDREN
127 (first children) ; returns AMANDA
128
129
130
131 
132 File: slisp, Node: flatc, Next: flatsize, Prev: first, Up: Xlisp Language Reference
133
134 flatc
135 =====
136
137 flatc
138 type: function (subr)
139 location: built-in
140 source file: xlfio.c and xlprin.c
141 Common LISP compatible: no
142 supported on: all machines
143
144 SYNTAX
145
146 (flatc <expr> )
147 <expr> - an expression
148
149 DESCRIPTION
150
151 The FLATC function determines the character length that would be
152 printed if the <expr> were printed using PRINC. This means that the
153 <expr> would be printed without a new-line. If <expr> is a string, it
154 would not be printed with quotes around the string. The print character
155 length is returned as the result.
156
157 EXAMPLES
158
159 (flatc 1234) ; returns 4
160 (flatc '(a b c)) ; returns 7
161 (flatc "abcd") ; returns 4
162 (flatc 'mybigsymbol) ; returns 11
163
164
165
166 
167 File: slisp, Node: flatsize, Next: flet, Prev: flatc, Up: Xlisp Language Reference
168
169 flatsize
170 ========
171
172 flatsize
173 type: function (subr)
174 location: built-in
175 source file: xlfio.c and xlprin.c
176 Common LISP compatible: no
177 supported on: all machines
178
179 SYNTAX
180
181 (flatsize <expr> )
182 <expr> - an expression
183
184 DESCRIPTION
185
186 The FLATSIZE function determines the character length that would be
187 printed if the <expr> were printed using PRIN1. This means that the
188 <expr> would be printed without a new-line. If <expr> is a string, it
189 would be printed with quotes around the string. The print character
190 length is returned as the result.
191
192 EXAMPLES
193
194 (flatsize 1234) ; returns 4
195 (flatsize '(a b c)) ; returns 7
196 (flatsize "abcd") ; returns 6
197 (flatsize 'mybigsymbol) ; returns 11
198
199
200
201 
202 File: slisp, Node: flet, Next: float, Prev: flatsize, Up: Xlisp Language Reference
203
204 flet
205 ====
206
207 flet
208 type: special form (fsubr)
209 location: built-in
210 source file: xlcont.c
211 Common LISP compatible: yes
212 supported on: all machines
213
214 SYNTAX
215
216 (flet ( [ <function> ... ] ) <expr> ... )
217 <function> - a function definition binding which is of the
218 form ( <symbol> <arg-list> <body> )
219 <symbol> - the symbol specifying the function name
220 <arg-list> - the argument list for the function
221 <body> - the body of the function
222 <expr> - an expression
223
224 DESCRIPTION
225
226 The FLET special form is basically a local block construct that
227 allows local <function> definitions followed by a block of code to
228 evaluate. The first form after the FLET is the 'binding' form. It
229 contains a series of <functions>. The FLET form will go through and
230 define the <symbol>s of the <functions> and then sequentially execute
231 the <expr>'s. The value of the last <expr> evaluated is returned.
232 When the FLET is finished execution, the <symbol>'s that were defined
233 will no longer exist.
234
235 EXAMPLES
236
237 (flet ( (fozz (x) (+ x x) )) ; an FLET with FOZZ local func.
238 (fozz 2)) ; returns 4
239 ; FOZZ no longer exists
240 (fozz 2) ; error: unbound function - FOZZ
241 ; an empty flet
242 (flet () (print 'a)) ; prints A
243
244 NOTE: FLET does not allow recursive definitions of functions. The
245 LABEL special form does allow this.
246
247
248
249 
250 File: slisp, Node: float, Next: *float-format*, Prev: flet, Up: Xlisp Language Reference
251
252 float
253 =====
254
255 float
256 type: function (subr)
257 location: built-in
258 source file: xlmath.c
259 Common LISP compatible: yes
260 supported on: all machines
261
262 SYNTAX
263
264 (float <expr> )
265 <expr> - integer or floating point number/expression
266
267 DESCRIPTION
268
269 The FLOAT function takes a numeric expression and returns the result
270 which is forced to be a floating point number.
271
272 EXAMPLES
273
274 (/ 1 2) ; returns 0 (integer division)
275 (/ (float 1) 2) ; returns 0.5
276 (float (/ 1 2)) ; returns 0 (integer division)
277 (/ 1 2 3) ; returns 0 (integer division)
278 (/ (float 1) 2 3) ; returns 0.166667
279
280
281
282 
283 File: slisp, Node: *float-format*, Next: floatp, Prev: float, Up: Xlisp Language Reference
284
285 *float-format*
286 ==============
287
288 *float-format*
289 type: system variable
290 location: built-in
291 source file: xlprin.c
292 Common LISP compatible: no
293 supported on: all machines
294
295 SYNTAX
296
297 *float-format*
298
299 DESCRIPTION
300
301 *FLOAT-FORMAT* is a system variable that allows a user to specify how
302 floating point numbers are to be printed by XLISP. The value of
303 *FLOAT-FORMAT* should be set to one of the string expressions "%e", "%f"
304 or "%g". These format strings are similar to C-language floating point
305 specifications.
306
307 format name description
308 ----------------------------------------------------------------
309 %e exponential The number is converted to decimal
310 notation of the form [-]m.nnnnnnE[+-]xx.
311 There is one leading digit. There are 6
312 digits after the decimal point.
313
314 %f decimal The number is converted to decimal
315 notation of the form [-]mmmmmm.nnnnnn .
316 There are as many digits before the
317 decimal point as necessary. There are 6
318 digits after the decimal point.
319
320 %g shortest The number is converted to either the
321 form of %e or %f, whichever produces the
322 shortest output string. Non-significant
323 zeroes are not printed.
324
325 The default value for *FLOAT-FORMAT* is the string "%g".
326
327 EXAMPLES
328
329 (setq *float-format* "%e") ; exponential notation
330 (print 1.0) ; prints 1.000000e+00
331 (print -9e99) ; prints -9.000000e+99
332 (setq *float-format* "%f") ; decimal notation
333 (print 1.0) ; prints 1.000000
334 (print 1.0e4) ; prints 10000.000000
335 (print -999.99e-99) ; prints -0.000000
336 (setq *float-format* "%g") ; shortest notation
337 (print 1.0) ; prints 1
338 (print 1.0e6) ; prints 1000000
339 (print 1.0e7) ; prints 1e+07
340 (print -999.999e99) ; prints -9.99999e+101
341 (setq *float-format* "SOMETHING") ; bad notation
342 (print 1.0) ; prints SOMETHING
343 (setq *float-format* "%g") ; reset to shortest notation
344
345 NOTE: There can be other characters put in the string, but in
346 general, this will not produce particularly desirable behaviour. There
347 is no error checking performed on the format string.
348
349
350
351 
352 File: slisp, Node: floatp, Next: fmakunbound, Prev: *float-format*, Up: Xlisp Language Reference
353
354 floatp
355 ======
356
357 floatp
358 type: predicate function (subr)
359 location: built-in
360 source file: xlbfun.c
361 Common LISP compatible: yes
362 supported on: all machines
363
364 SYNTAX
365
366 (floatp <expr> )
367 <expr> - the expression to check
368
369 DESCRIPTION
370
371 The FLOATP predicate checks if an <expr> is a floating point number.
372 T is returned if <expr> is a floating point number, NIL is returned
373 otherwise.
374
375 EXAMPLES
376
377 (floatp 1.2) ; returns T - float
378 (floatp '1.2) ; returns T - still a float
379 (setq a 1.234) ;
380 (floatp a) ; returns T - evaluates to float
381 (floatp 0.0) ; returns T - float zero
382 (floatp 0) ; returns NIL - integer zero
383 (floatp 1) ; returns NIL - integer
384 (floatp #x034) ; returns NIL - integer readmacro
385 (floatp 'a) ; returns NIL - symbol
386 (floatp #\a) ; returns NIL - character
387 (floatp NIL) ; returns NIL - NIL
388 (floatp #(0 1 2)) ; returns NIL - array
389
390
391
392 
393 File: slisp, Node: fmakunbound, Next: format, Prev: floatp, Up: Xlisp Language Reference
394
395 fmakunbound
396 ===========
397
398 fmakunbound
399 type: defined function (closure)
400 location: extension
401 source file: init.lsp
402 Common LISP compatible: yes
403 supported on: all machines
404
405 SYNTAX
406
407 (fmakunbound <symbol> )
408 <symbol> - an expression evaluating to a symbol
409
410 DESCRIPTION
411
412 The FMAKUNBOUND function makes a symbol's function definition
413 unbound. The <symbol> must be a valid symbol, but it does not need to
414 have a definition. The FMAKUNBOUND function returns the symbol as its
415 result.
416
417 EXAMPLES
418
419 (defun myfn () (print "hi")) ; define MYFN
420 (myfn) ; prints "hi"
421 (fmakunbound 'myfn) ; returns MYFN
422 (myfn) ; error: unbound function - MYFN
423
424 NOTE: FMAKUNBOUND is not misspelled - there is no 'e' in it.
425
426 NOTE: The FMAKUNBOUND works on functions (closures) in the same way
427 that MAKUNBOUND works on variables. Be sure to use the correct one for
428 what you are unbinding. These functions do not generate an error if
429 you try to unbind the wrong type. This is because of the definition of
430 these functions and the fact that the function and variable name spaces
431 are separate. You can have both a function called FOO and a variable
432 called FOO.
433
434 NOTE: The function FMAKUNBOUND is created in the INIT.LSP file. If
435 it does not exist in your XLISP system, you might be having a problem
436 with INIT.LSP. Before you start XLISP, look in the directory you are
437 currently in, and check to see if there is an INIT.LSP.
438
439
440
441 
442 File: slisp, Node: format, Next: fourth, Prev: fmakunbound, Up: Xlisp Language Reference
443
444 format
445 ======
446
447 format
448 type: function (subr)
449 location: built-in
450 source file: xlfio.c
451 Common LISP compatible: similar
452 supported on: all machines
453
454 SYNTAX
455
456 (format <destination> <format> [ <expr1> ... ] )
457 <destination> - a required destination - must be a file
458 pointer, a stream, NIL (to create a string)
459 or T (to print to *standard-output*)
460 <format> - a format string
461 <exprN> - an expression
462
463 DESCRIPTION
464
465 The FORMAT function prints the specified expressions (if any) to the
466 specified <destination> using the <format> string to control the print
467 format. If the <destination> is NIL, a string is created and returned
468 with the contents of the FORMAT. If the <destination> is T, the
469 printing occurs to *STANDARD-OUTPUT*. FORMAT returns a NIL, if the
470 <destination> was non-NIL. The <format> string is a string (surrounded
471 by double-quote characters). This string contains ASCII text to be
472 printed along with formatting directives (identified by a preceeding
473 tilde ~ character). The character following the tilde character is not
474 case sensitive (~a and ~A will function equivalently).
475
476 EXAMPLES
477
478 (format T "Now is the time for") ; prints Now is the time for
479 (format T "all ~A ~S to" 'good 'men) ; prints all GOOD MEN to
480 (format T "come to the") ; prints come to the
481 (format T "~A of their ~S" ; prints aid of their "party"
482 "aid" "party") ;
483 (format *standard-ouput* "Hello there") ; prints Hello there
484 (format nil "ho ho ~S" 'ho) ; returns "ho ho HO"
485 (format T "this is ~%a break") ; prints this is
486 ; a break
487 (format T "this is a long ~
488 string") ; prints this is a long string
489
490 SUPPORTED FORMAT DIRECTIVES: The <format> string in XLISP supports
491 the following format directives:
492
493 directive name action
494 ----------------------------------------------------------------
495 ~A ASCII Print the <expr>.
496
497 If it is a string print it
498 without quotes. This is like
499 the PRINC function.
500
501 ~S S-EXPR Print the <expr>.
502
503 If it is a string print it with
504 quotes. This is like the PRIN1
505 function.
506
507 ~% NEW-LINE Print a new line.
508
509 ~~ TILDE Print a single tilde ~ character.
510
511 ~<new-line> CONTINUE Continue the <format> string on
512 the next line.
513
514 This signals a line break in the
515 format. The FORMAT will ignore
516 all white-space (blanks, tabs,
517 newlines). This is useful when
518 the <format> string is longer
519 than a program line. Note that
520 the new-line character must
521 immediately follow the tilde
522 character.
523
524 COMMON LISP COMPATIBILITY: The FORMAT function in Common LISP is
525 quite impressive. It includes 26 different formatting directives.
526 XLISP, as shown above, does not include most of these. The more
527 difficult ones that you might encounter are the Decimal, Octal,
528 heXidecimal, Fixed-format floating-point and Exponential
529 floating-point. It is possible to print in octal and hexadecimal
530 notation by setting *INTEGER-FORMAT*. It is possible to print in fixed
531 format and exponential by setting *FLOAT-FORMAT*. However, neither of
532 these system variables are supported in Common LISP and neither gives
533 control over field size.
534
535
536
537 
538 File: slisp, Node: fourth, Next: funcall, Prev: format, Up: Xlisp Language Reference
539
540 fourth
541 ======
542
543 fourth
544 type: function (subr)
545 location: built-in
546 source file: xlinit.c
547 Common LISP compatible: yes
548 supported on: all machines
549
550 SYNTAX
551
552 (fourth <expr> )
553 <expr> - a list or list expression
554
555 DESCRIPTION
556
557 FOURTH returns the fourth element of a list or list expression. If
558 the list is NIL, NIL is returned.
559
560 EXAMPLES
561
562 (fourth '(1 2 3 4 5)) ; returns 4
563 (fourth NIL) ; returns NIL
564 (setq kids '(junie vickie cindy chris)) ; set up variable KIDS
565 (first kids) ; returns JUNIE
566 (second kids) ; returns VICKIE
567 (third kids) ; returns CINDY
568 (fourth kids) ; returns CHRIS
569 (rest kids) ; returns (VICKIE CINDY CHRIS)
570
571 NOTE: This function is set to the same code as CADDDR.
572
573
574
575 
576 File: slisp, Node: funcall, Next: function, Prev: fourth, Up: Xlisp Language Reference
577
578 funcall
579 =======
580
581 funcall
582 type: function (subr)
583 location: built-in
584 source file: xlbfun.c
585 Common LISP compatible: yes
586 supported on: all machines
587
588 SYNTAX
589
590 (funcall <function> [<arg1> ... ] )
591 <function> - the function or symbol to be called
592 <argN> - an argument to be passed to <function>
593
594 DESCRIPTION
595
596 FUNCALL calls a function with a series of arguments. FUNCALL returns
597 the result from <function>.
598
599 EXAMPLES
600
601 (funcall '+ 1 2 3 4) ; returns 10
602 (funcall #'+ 1 2 3 4) ; returns 10
603 (funcall '+ '1 '2 '3) ; returns 6
604 (setq sys-add (function +)) ; returns #<Subr-+: #22c32>
605 (setq a 99) ;
606 (funcall sys-add 1 a) ; 100
607 (funcall sys-add 1 'a) ; error: bad argument type
608 ; you can't add a symbol
609 ; only it's value
610 (setq a 2) (setq b 3) ; set A and B values
611 (funcall (if (< a b) (function +) ; <function> can be computed
612 (function -)) ;
613 a b) ; returns 5
614 (defun add-to-list (arg list) ; add a list or an atom
615 (funcall (if (atom arg) 'cons ; to the front of a list
616 'append) ;
617 arg list)) ;
618 (add-to-list 'a '(b c)) ; returns (A B C)
619 (add-to-list '(a b) '(b c)) ; returns (A B B C)
620
621
622
623 
624 File: slisp, Node: function, Next: gc, Prev: funcall, Up: Xlisp Language Reference
625
626 function
627 ========
628
629 function
630 type: special form (fsubr)
631 location: built-in
632 source file: xlcont.c
633 Common LISP compatible: yes
634 supported on: all machines
635
636 SYNTAX
637
638 (function <expr> )
639 <expr> - an expression that evaluates to a function
640
641 DESCRIPTION
642
643 FUNCTION returns the function definition of the <expr>. Execution of
644 the <expr> form does not occur. FUNCTION will operate on functions,
645 special forms, lambda-expressions and macros.
646
647 EXAMPLES
648
649 (function car) ; returns #<Subr-CAR: #23ac4>
650 (function quote) ; returns #<FSubr-QUOTE: #23d1c>
651 #'quote ; returns #<FSubr-QUOTE: #23d1c>
652 (function 'cdr) ; error: not a function
653 (defun foo (x) (+ x x)) ; define FOO function
654 (function foo) ; returns #<Closure-FOO: #2cfb6>
655 (defmacro bar (x) (+ x x)) ; define FOOMAC macro
656 (function bar) ; returns #<Closure-BAR: #2ceee>
657 (setq my 99) ; define a variable
658 (function my) ; error: unbound function
659 (defun my (x) (print x)) ; define a function
660 (function my) ; returns #<Closure-MY: #2cdd6>
661 ;
662 ; NOTE THAT THERE ARE 2 SYMBOLS
663 ; A VARIABLE my AND A FUNCTION
664 ; my.
665
666 READ MACRO: XLISP supports the normal read macro of a hash and
667 quote (#') as a short-hand method of writing the FUNCTION special form.
668
669
670
671 
672 File: slisp, Node: gc, Next: gcd, Prev: function, Up: Xlisp Language Reference
673
674 gc
675 ==
676
677 gc
678 type: function (subr)
679 location: built-in
680 source file: xldmem.c
681 Common LISP compatible: yes
682 supported on: all machines
683
684 SYNTAX
685
686 (gc)
687
688 DESCRIPTION
689
690 The GC function forces a garbage collection of the unused memory of
691 XLISP. NIL is always returned.
692
693 EXAMPLES
694
695 (gc) ; force a garbage collection
696
697 NOTE: The system will cause an automatic garbage collection if it
698 runs out of free memory.
699
700 NOTE: When GC is called or an automatic garbage collection occurs,
701 if the amount of free memory is still low after the garbage collection,
702 the system attempts to add more segments (an automatic EXPAND).
703
704
705
706 
707 File: slisp, Node: gcd, Next: *gc-flag*, Prev: gc, Up: Xlisp Language Reference
708
709 gcd
710 ===
711
712 gcd
713 type: function (subr)
714 location: built-in
715 source file: xlmath.c
716 Common LISP compatible: yes
717 supported on: all machines
718
719 SYNTAX
720
721 (gcd [ <int> ... ] )
722 <int> - an integer expression
723
724 DESCRIPTION
725
726 The GCD function returns the greatest common divisor of a series of
727 integers. If no arguments are given, a zero is returned. If only one
728 argument is given, the absolute value of the argument is returned. The
729 successful result is always a positive integer.
730
731 EXAMPLES
732
733 (gcd 51 34) ; returns 17
734 (gcd 99 66 22) ; returns 11
735 (gcd -99 66 -33) ; returns 33
736 (gcd -14) ; returns 14
737 (gcd 0) ; returns 0
738 (gcd) ; returns 0
739 (gcd .2) ; error: bad argument type - 0.2
740
741
742
743 
744 File: slisp, Node: *gc-flag*, Next: *gc-hook*, Prev: gcd, Up: Xlisp Language Reference
745
746 *gc-flag*
747 =========
748
749 *gc-flag*
750 type: system variable
751 location: built-in
752 source file: xldmem.c
753 Common LISP compatible: no
754 supported on: all machines
755
756 SYNTAX
757
758 *gc-flag*
759
760 DESCRIPTION
761
762 *GC-FLAG* is a system variable that controls the printing of a
763 garbage collection message. If *GC-FLAG* is NIL, no garbage collection
764 messages will be printed. If *GC-FLAG* is non-NIL, a garbage
765 collection message will be printed whenever a GC takes place. The
766 default value for *GC-FLAG* is NIL. The message will be of the form:
767
768 [ gc: total 4000, 2497 free ]
769
770 EXAMPLES
771
772 *gc-flag* ; returns NIL
773 (gc) ; returns NIL
774 (setq *gc-flag* T) ; set up for message
775 (gc) ; prints a gc message
776
777
778
779 
780 File: slisp, Node: *gc-hook*, Next: gensym, Prev: *gc-flag*, Up: Xlisp Language Reference
781
782 *gc-hook*
783 =========
784
785 *gc-hook*
786 type: system variable
787 location: built-in
788 source file: xldmem.c
789 Common LISP compatible: no
790 supported on: all machines
791
792 SYNTAX
793
794 *gc-hook*
795
796 DESCRIPTION
797
798 *GC-HOOK* is a system variable that allows a user function to be
799 performed everytime garbage is collected (either explicitly with GC or
800 automatically). The default value for *GC-HOOK* is NIL. When *GC-HOOK*
801 is set to a non-NIL symbol, it is enabled to execute the specified user
802 routine. The user routine can be a quoted symbol or a closure. There
803 are two parameters to the user routine - the total number of nodes and
804 current free nodes after the garbage collection.
805
806 EXAMPLES
807
808 *gc-hook* ; returns NIL
809 (gc) ; returns NIL
810 (defun mygchook (&rest stuff) ; define the hook
811 (print stuff) ;
812 (print "my hook")) ;
813 (setq *gc-hook* 'mygchook) ; set up *GC-HOOK*
814 (gc) ; prints (2640 232)
815 ; "my hook"
816 ; returns NIL
817 (setq *gc-flag* T) ; turn on the system GC message
818 (gc) ; prints
819 ; [ gc: total 2640, (2640 241)
820 ; "my hook"
821 ; 236 free ]
822 ; returns NIL
823 (setq *gc-flag* NIL) ; turn off GC message
824 (setq *gc-hook* (lambda (x y) ; enable user routine
825 (princ "\007"))) ; that beeps at every GC
826 (gc) ; beeps
827 (defun expand-on-gc (total free) ; define EXPAND-ON-GC
828 (if (< (/ free 1.0 total) .1) ; IF free/total < .10
829 (progn (expand 2) ; THEN expand memory
830 (princ "\007") ) ; and beep
831 ) ; ELSE do nothing
832 ) ; NOTE: XLISP already gets more
833 ; nodes automatically,
834 ; this is just an example.
835 (setq *gc-hook* 'expand-on-gc) ; enable EXPAND-ON-GC
836 (gc) ; beeps when low on nodes
837
838 NOTE: The *GC-HOOK* and *GC-FLAG* facilities can interact. If you
839 do printing in the *GC-HOOK* user form and enable *GC-FLAG*, the
840 *GC-HOOK* printing will come out in the middle of the *GC-FLAG* message.
841
842 NOTE: The *GC-HOOK* user form is evaluated after the execution of
843 the actual garbage collection code. This means that if the user form
844 causes an error, it does not prevent a garbage collection.
845
846 NOTE: Since *GC-HOOK* is set to a symbol, the user defined form can
847 be changed by doing another DEFUN (or whatever) to the symbol in
848 *GC-HOOK*. Note also that you should define the symbol first and then
849 set *GC-HOOK* to the symbol. If you don't, an automatic garbage
850 collection might occur before you set *GC-HOOK* - generating an error
851 and stopping your program.
852
853
854
855 
856 File: slisp, Node: gensym, Next: get, Prev: *gc-hook*, Up: Xlisp Language Reference
857
858 gensym
859 ======
860
861 gensym
862 type: function (subr)
863 location: built-in
864 source file: xlbfun.c
865 Common LISP compatible: yes
866 supported on: all machines
867
868 SYNTAX
869
870 (gensym [<tag>])
871 <tag> - an optional integer or string
872
873 DESCRIPTION
874
875 GENSYM generates and returns a symbol.
876
877 The default symbol form is as a character G followed by a number -
878 Gn. The default numbering starts at 1. You can change what the
879 generated symbol looks like. By calling GENSYM with a string <tag>,
880 the default string is set to string parameter. If an integer number is
881 the <tag>, the current number is set to the integer parameter.
882
883 EXAMPLES
884
885 (gensym) ; first time => G1
886 (gensym 100) ; returns G100
887 (gensym "MYGENSYM") ; returns MYGENSYM101
888 (gensym 0) ; returns MYGENSYM0
889 (gensym) ; returns MYGENSYM1
890 (gensym "G") ; \
891 (gensym 0) ; / put it back to 'normal'
892 (gensym) ; just like first time => G1
893
894 NOTE: It takes 2 calls to GENSYM to set both portions of the GENSYM
895 symbol.
896
897 NOTE: Although it is possible to call GENSYM with numbers in the
898 string (like "AB1"), this does generate an odd sequence. What will
899 happen is you will get a sequence of symbols like .....AB18 AB19 AB110
900 AB111.....
901
902
903
904 
905 File: slisp, Node: get, Next: get-key, Prev: gensym, Up: Xlisp Language Reference
906
907 get
908 ===
909
910 get
911 type: function (subr)
912 location: built-in
913 source file: xlbfun.c
914 Common LISP compatible: similar
915 supported on: all machines
916
917 SYNTAX
918
919 (get <symbol> <property> )
920 <symbol> - the symbol with a property list
921 <property> - the property name being retrieved
922
923 DESCRIPTION
924
925 GET returns the value of the <property> from the <symbol>. If the
926 <property> does not exist, a NIL is returned. The <symbol> must be an
927 existing symbol. The returned value may be a single value or a list.
928
929 Property lists are lists attached to any user defined variables.
930 The lists are in the form of (name1 val1 name2 val2 ....). Any
931 number of properties may be attached to a single variable.
932
933 EXAMPLES
934
935 (setq person 'bobby) ; create a var with a value
936 (putprop person 'boogie 'last-name) ; add a LAST-NAME property
937 (putprop person 'disc-jockey 'job) ; add a JOB property
938 (get person 'last-name) ; retrieve LAST-NAME - boogie
939 (get person 'job) ; retrieve JOB - disc-jockey
940 (get person 'height) ; non-existant - returns NIL
941 (putprop person '(10 20 30) 'stats) ; add STATS - a list
942 (get person 'stats) ;
943
944 NOTE: You can set a property to the value NIL. However, this NIL
945 value is indistinguishable from the NIL returned when a property does
946 not exist.
947
948 COMMON LISP COMPATIBILITY: Common LISP allows for an optional
949 default value, which XLISP does not support.
950
951
952
953 
954 File: slisp, Node: get-key, Next: get-lambda-expression, Prev: get, Up: Xlisp Language Reference
955
956 get-key
957 =======
958
959 get-key
960 type: function (subr)
961 location: built-in
962 source file: msstuff.c and osdefs.h and osptrs.h
963 Common LISP compatible: no
964 supported on: MS-DOS compatibles
965
966 SYNTAX
967
968 (get-key)
969
970 DESCRIPTION
971
972 The GET-KEY function gets a single key stroke from the keyboard (as
973 opposed to an entire line - as READ does).
974
975 EXAMPLES
976
977 (setq mychar (get-key)) ; get a character
978
979 NOTE: This function is an extension of the XLISP system. It is
980 provided in the MSSTUFF.C source code file. If your XLISP system is
981 built for an IBM PC and compatibles or MS-DOS, this function will work.
982 If your system is built on UNIX or some other operating system, it is
983 unlikely that these functions will work unless you extend STUFF.C.
984
985
986
987 
988 File: slisp, Node: get-lambda-expression, Next: get-macro-character, Prev: get-key, Up: Xlisp Language Reference
989
990 get-lambda-expression
991 =====================
992
993 get-lambda-expression
994 type: function (subr)
995 location: built-in
996 source file: xlcont.c
997 Common LISP compatible: no
998 supported on: all machines
999
1000 SYNTAX
1001
1002 (get-lambda-expression <closure> )
1003 <closure> - a closure object from a previously defined
1004 function.
1005
1006 DESCRIPTION
1007
1008 The GET-LAMBDA-EXPRESSION function takes the <closure> object and
1009 returns a reconstruction of a LAMBDA or a MACRO expression that defines
1010 the <closure>. The parameter must be a <closure> expression (of the the
1011 form #<Closure-FUNC #277e2> ).
1012
1013 EXAMPLES
1014
1015 (defun mine (a b) (print (+ a b))) ; define MINE defun
1016 (get-lambda-expression (function mine)) ; returns (LAMBDA (A B)
1017 ; (PRINT (+ A B)))
1018 (get-lambda-expression ;
1019 (lambda (a) (print a)) ; returns (LAMBDA (A) (PRINT A))
1020 (defmacro plus (n1 n2) `(+ ,n1 ,n2)) ; define PLUS macro
1021 (get-lambda-expression (function plus)) ; returns
1022 ; (MACRO (N1 N2)
1023 ; (BACKQUOTE (+ (COMMA N1)
1024 ; (COMMA N2))))
1025
1026
1027
1028 
1029 File: slisp, Node: get-macro-character, Next: get-output-stream-list, Prev: get-lambda-expression, Up: Xlisp Language Reference
1030
1031 get-macro-character
1032 ===================
1033
1034 get-macro-character
1035 type: defined function (closure)
1036 location: extension
1037 source file: init.lsp
1038 Common LISP compatible: related
1039 supported on: all machines
1040
1041 SYNTAX
1042
1043 (get-macro-character <char-num> )
1044 <char-num> - an integer expression
1045
1046 DESCRIPTION
1047
1048 The GET-MACRO-CHARACTER function returns the code that will be
1049 executed when the specified character <char-num> is encountered by the
1050 XLISP reader. The returned value is taken from the *READTABLE* system
1051 variable which contains the reader table array. The table is 128
1052 entries (0..127) for each of the 7-bit ASCII characters that XLISP can
1053 read. Each entry in the table must be one of NIL, :CONSTITUENT,
1054 :SESCAPE, :MESCAPE, :WHITE-SPACE, a :TMACRO dotted pair or a :NMACRO
1055 dotted pair. The GET-MACRO-CHARACTER function will return a NIL value
1056 if the table entry is NIL, :CONSTITUENT, :SESCAPE, :MESCAPE or
1057 :WHITE-SPACE. If the table entry is :TMACRO or :NMACRO, then the code
1058 associated with the entry is returned. :TMACRO is used for a
1059 terminating read-macro. :NMACRO is used for a non-terminating
1060 read-macro. GET-MACRO-CHARACTER does not differentiate whether the code
1061 returned is a :TMACRO or an :NMACRO. The function returned may be a
1062 built-in read-macro function or a user defined lambda expression. The
1063 function takes two parameters, an input stream specification, and an
1064 integer that is the character value. The <function> should return NIL
1065 if the character is 'white-space' or a value CONSed with NIL to return
1066 the value.
1067
1068 EXAMPLES
1069
1070 (get-macro-character #\( ) ; returns #<Subr-: #2401e>
1071 (get-macro-character #\# ) ; returns #<Subr-: #24082>
1072 (get-macro-character #\Space ) ; returns NIL
1073
1074 NOTE: In the normal XLISP system the following characters have code
1075 associated with them in the *READTABLE*:
1076
1077 " # ' ( ) , ; `
1078
1079 NOTE: The functions GET-MACRO-CHARACTER and SET-MACRO-CHARACTER are
1080 created in the INIT.LSP file. If they do not exist in your XLISP
1081 system, you might be having a problem with INIT.LSP. Before you start
1082 XLISP, look in the directory you are currently in, and check to see if
1083 there is an INIT.LSP.
1084
1085 COMMON LISP COMPATIBILITY: The GET-MACRO-CHARACTER function is
1086 somewhat related to the Common LISP GET-DISPATCH-MACRO-CHARACTER
1087 function.
1088
1089
1090
1091 
1092 File: slisp, Node: get-output-stream-list, Next: get-output-stream-string, Prev: get-macro-character, Up: Xlisp Language Reference
1093
1094 get-output-stream-list
1095 ======================
1096
1097 get-output-stream-list
1098 type: function (subr)
1099 location: built-in
1100 source file: xlfio.c
1101 Common LISP compatible: no
1102 supported on: all machines
1103
1104 SYNTAX
1105
1106 (get-output-stream-list <source> )
1107 <source> - an output stream expression
1108
1109 DESCRIPTION
1110
1111 The GET-OUTPUT-STREAM-LIST function empties the specified <source>
1112 and returns this data as a list. The output stream is emptied by this
1113 operation.
1114
1115 EXAMPLES
1116
1117 (setq out (make-string-output-stream)) ; returns #<Unnamed-Stream: #2d2cc>
1118 (format out "123") ; add some data to output stream
1119 (get-output-stream-list out) ; returns (#\1 #\2 #\3)
1120 (format out "123") ; add some data to output stream
1121 (read out) ; returns 123
1122 (get-output-stream-list out) ; returns NIL
1123
1124
1125
1126 
1127 File: slisp, Node: get-output-stream-string, Next: go, Prev: get-output-stream-list, Up: Xlisp Language Reference
1128
1129 get-output-stream-string
1130 ========================
1131
1132 get-output-stream-string
1133 type: function (subr)
1134 location: built-in
1135 source file: xlfio.c
1136 Common LISP compatible: yes
1137 supported on: all machines
1138
1139 SYNTAX
1140
1141 (get-output-stream-string <source> )
1142 <source> - an output stream expression
1143
1144 DESCRIPTION
1145
1146 The GET-OUTPUT-STREAM-STRING function empties the specified <source>
1147 and returns this data as a single string. The output stream is emptied
1148 by this operation.
1149
1150 EXAMPLES
1151
1152 (make-string-output-stream) ; returns #<Unnamed-Stream: #2d9c0>
1153 (setq out (make-string-output-stream)) ; returns #<Unnamed-Stream: #2d95c>
1154 (format out "fee fi fo fum ") ; \
1155 (format out "I smell the blood of ") ; fill up output stream
1156 (format out "Elmer Fudd") ; /
1157 (get-output-stream-string out) ; returns
1158 ; "fee fi fo fum I smell
1159 ; the blood of Elmer Fudd"
1160 (format out "~%now what") ; add more to output stream
1161 (get-output-stream-string out) ; returns "\nnow what"
1162 (get-output-stream-string out) ; returns ""
1163 (format out "hello") ; add more to output stream
1164 (read out) ; returns HELLO
1165
1166
1167
1168 
1169 File: slisp, Node: go, Next: hash, Prev: get-output-stream-string, Up: Xlisp Language Reference
1170
1171 go
1172 ==
1173
1174 go
1175 type: special form (fsubr)
1176 location: built-in
1177 source file: xlcont.c
1178 Common LISP compatible: yes
1179 supported on: all machines
1180
1181 SYNTAX
1182
1183 (go <tag-symbol> )
1184 <tag-symbol> - a symbol
1185
1186 DESCRIPTION
1187
1188 The GO special form allows 'go-to' style branching within 'block'
1189 constructs (DO, DO*, DOLIST, DOTIMES, TAGBODY, LOOP, PROG and PROG*).
1190 The <tag-symbol> is the 'label' and must exist somewhere within the
1191 'block' that the GO occurs within. Otherwise an error will be generated
1192 - "error: no target for GO". GO never returns a value. If the
1193 <tag-symbol> exists, then the execution will continue immediately after
1194 the <tag-symbol>.
1195
1196 EXAMPLES
1197
1198 (defun foo (i j) ; define FOO
1199 (prog () ; with a PROG
1200 (print "begin") ;
1201 start (print j) ; tag - START
1202 (setq j (1- j)) ;
1203 (if (eql i j) (GO start) ; 2-way branch
1204 (GO end)) ;
1205 (print "hello") ; won't ever be reached
1206 end (print "done") ; tag - END
1207 (return 42))) ;
1208 (foo 1 2) ; prints "begin" 2 1 "done"
1209 ; returns 42
1210 (foo 2 1) ; prints "begin" 1 "done"
1211 ; returns 42
1212
1213 NOTE: Although GO will accept a <tag-symbol> that is not a symbol,
1214 it will not find this improper <tag-symbol>. An error will be
1215 generated - "error: no target for GO".
1216
1217
1218
1219 
1220 File: slisp, Node: hash, Next: if, Prev: go, Up: Xlisp Language Reference
1221
1222 hash
1223 ====
1224
1225 hash
1226 type: function (subr)
1227 location: built-in
1228 source file: xlbfun.c and xlsym.c
1229 Common LISP compatible: no
1230 supported on: all machines
1231
1232 SYNTAX
1233
1234 (hash <name> <table-size> )
1235 <name> - a symbol or string expression
1236 <table-size> - an integer expression
1237
1238 DESCRIPTION
1239
1240 The HASH function computes and returns an integer index for a given
1241 symbol <name> and a given size of hash table <table-size>. The
1242 intention is for HASH to be used with tables made by MAKE-ARRAY and
1243 accessed by AREF.
1244
1245 EXAMPLES
1246
1247 (hash "zzzz" 1000) ; returns index 322
1248 (hash "ZZZZ" 1000) ; returns index 626
1249 (hash 'ZZZZ 1000) ; returns index 626
1250 (hash "hiho" 1000) ; returns index 519
1251 (hash 'hiho 1000) ; returns index 143
1252 (hash "abcd" 1000) ; returns index 72
1253 (defun lookin (sym) ; create a function to
1254 (aref *obarray* ; look inside *OBARRAY*
1255 (hash sym (length *obarray*)))); and look for a specific
1256 ; symbol - returns a list
1257 (lookin 'caar) ; returns the hash table entry
1258 ; (ZEROP CDDDDR CAAR HASH)
1259
1260 NOTE: This is a useful function for creating and accessing tables.
1261 It is also useful for looking inside of XLISP's own symbol table
1262 *OBARRAY*.
1263
1264
1265
1266 
1267 File: slisp, Node: if, Next: int-char, Prev: hash, Up: Xlisp Language Reference
1268
1269 if
1270 ==
1271
1272 if
1273 type: special form (fsubr)
1274 location: built-in
1275 source file: xlcont.c
1276 Common LISP compatible: yes
1277 supported on: all machines
1278
1279 SYNTAX
1280
1281 (if <test-expr> <then-expr> [ <else-expr> ] )
1282 <test-expr> - an expression
1283 <then-expr> - the THEN-CLAUSE, an expression
1284 <else-expr> - the ELSE-CLAUSE, an optional expression
1285
1286 DESCRIPTION
1287
1288 The IF special form evaluates the <test-expr>. If <test-expr>
1289 evaluates to a non-NIL value, then <then-expr> is evaluated and
1290 returned as the result. If <test-expr> evaluates to NIL and there is
1291 an <else-expr>, then the <else-expr> is evaluated and its result is
1292 returned. If there is no <else-expr> and <test-expr> evaluates to NIL,
1293 then NIL is returned as a result.
1294
1295 EXAMPLES
1296
1297 (if T (print "will print") ; prints "will print"
1298 (print "won't print")) ;
1299 (if NIL (print "won't print") ;
1300 (print "will print")) ; prints "will print"
1301 (if 'a T NIL) ; returns T
1302 (if NIL 'nope 'yep) ; returns YEP
1303
1304
1305
1306 
1307 File: slisp, Node: int-char, Next: *integer-format*, Prev: if, Up: Xlisp Language Reference
1308
1309 int-char
1310 ========
1311
1312 int-char
1313 type: function (subr)
1314 location: built-in
1315 source file: xlstr.c
1316 Common LISP compatible: similar
1317 versions: all machines
1318
1319 SYNTAX
1320
1321 (int-char <int> )
1322 <int> - an integer numeric expression
1323
1324 DESCRIPTION
1325
1326 The INT-CHAR function returns a character which is the result of
1327 turning the <int> expression into a character. If a <int> cannot be
1328 made into a character, an error is signalled. The range that <int>
1329 produces a valid character is 0 through 255.
1330
1331 EXAMPLES
1332
1333 (int-char 48) ; returns #\0
1334 (int-char 65) ; returns #\A
1335 (int-char 97) ; returns #\a
1336 (int-char 91) ; returns #\[
1337 (int-char 10) ; returns #\Newline
1338 (int-char 999) ; error - character code out of
1339 ; range - 999
1340
1341 COMMON LISP COMPATIBILITY: Common LISP specifies that INT-CHAR
1342 should return a NIL when there is no valid character for the integer
1343 value being passed in. XLISP generates an error in these cases. In
1344 some cases it is possible to substitue the CODE-CHAR function for
1345 INT-CHAR.
1346
1347 NOTE: Unlike the CHAR-CODE and CHAR-INT functions, CODE-CHAR and
1348 INT-CHAR are not identical in use. CODE-CHAR accepts 0..127 for its
1349 range and then produces NIL results. INT-CHAR accepts 0..255 for its
1350 range and then produces errors.
1351
1352
1353
1354 
1355 File: slisp, Node: *integer-format*, Next: integerp, Prev: int-char, Up: Xlisp Language Reference
1356
1357 *integer-format*
1358 ================
1359
1360 *integer-format*
1361 type: system variable
1362 location: built-in
1363 source file: xlprin.c
1364 Common LISP compatible: no
1365 supported on: all machines
1366
1367 SYNTAX
1368
1369 *integer-format*
1370
1371 DESCRIPTION
1372
1373 *INTEGER-FORMAT* is a system variable that allows a user to specify
1374 how integer numbers are to be printed by XLISP. The value of
1375 *INTEGER-FORMAT* should be set to one of the string expressions "%ld",
1376 "%lo" or "%lx". The character after the percent character is the
1377 alphabetic 'ell' character. These format strings are similar to
1378 C-language floating point specifications.
1379
1380 format description
1381 ---------------------------------------------------
1382 "%ld" decimal
1383 "%lu" unsigned decimal
1384 "%lo" unsigned octal
1385 "%lx" unsigned hexadecimal
1386
1387 The default value for *INTEGER-FORMAT* is the string "%ld".
1388
1389 EXAMPLES
1390
1391 *integer-format* ; returns "%ld"
1392 ;
1393 (setq *integer-format* "%ld") ; signed decimal
1394 (print 1) ; prints 1
1395 (print 1234) ; prints 1234
1396 (print -1) ; prints -1
1397 (print -1234) ; prints -1234
1398 ;
1399 (setq *integer-format* "%lo") ; octal notation
1400 (print 1) ; prints 1
1401 (print 1234) ; prints 2322
1402 (print -1) ; prints 37777777777
1403 (print -1234) ; prints 37777775456
1404 ;
1405 (setq *integer-format* "%lx") ; hexadecimal notation
1406 (print 1) ; prints 1
1407 (print -1) ; prints ffffffff
1408 (print 1234) ; prints 4d2
1409 (print -1234) ; prints fffffb2e
1410 ;
1411 (setq *integer-format* "%u") ; unsigned decimal
1412 (print 1) ; prints 1
1413 (print 1234) ; prints 1234
1414 (print -1) ; prints 4294967295
1415 (print -1234) ; prints 4294966062
1416 ;
1417 (setq *integer-format* "hi") ; a bad notation
1418 (print 1) ; prints hi
1419 (print 9999) ; prints hi
1420 ;
1421 (setq *integer-format* "%ld") ; reset to original "%ld"
1422
1423 NOTE: There can be other characters put in the string, but in
1424 general, this will not produce particularly desirable behaviour. There
1425 is no error checking performed on the format string.
1426
1427
1428

brinkley@uw.edu
ViewVC Help
Powered by ViewVC 1.1.26