|
|
1.1 root 1:
2:
3:
4:
5:
6:
7:
8: CHAPTER 1
9:
10:
11: FRANZ LISP
12:
13:
14:
15:
16:
17:
18: 1.1. FRANZ LISP[] was created as a tool to further
19: research in symbolic and algebraic manipulation,
20: artificial intelligence, and programming languages at
21: the University of California at Berkeley. Its roots
22: are in a PDP-11 Lisp system which originally came from
23: Harvard. As it grew it adopted features of Maclisp
24: and Lisp Machine Lisp which enables our work to be
25: shared with colleagues at the Laboratory for Computer
26: Science at M.I.T. Substantial compatibility with
27: other Lisp dialects (Interlisp, UCILisp, CMULisp) is
28: achieved by means of support packages and compiler
29: switches. The heart of FRANZ LISP is written almost
30: entirely in the programming language C. Of course, it
31: has been greatly extended by additions written in
32: Lisp. A small part is written in the assembly
33: language for the current host machines, VAXen and a
34: couple of flavors of 68000. Because FRANZ LISP is
35: written in C, it is relatively portable and easy to
36: comprehend.
37:
38: FRANZ LISP is capable of running large lisp pro-
39: grams in a timesharing environment, has facilities for
40: arrays and user defined structures, has a user con-
41: trolled reader with character and word macro capabil-
42: ities, and can interact directly with compiled Lisp,
43: C, Fortran, and Pascal code.
44:
45: This document is a reference manual for the FRANZ
46: LISP system. It is not a Lisp primer or introduction
47: to the language. Some parts will be of interest only
48: to those maintaining FRANZ LISP at their computer
49: site. This document is divided into four Movements.
50: In the first one we will attempt to describe the
51: language of FRANZ LISP precisely and completely as it
52: now stands (Opus 38.69, June 1983). In the second
53: Movement we will look at the reader, function types,
54: ____________________
55: 9 []It is rumored that this name has something to do with
56: Franz Liszt [F_rants List] (1811-1886) a Hungarian composer
57: and keyboard virtuoso. These allegations have never been
58: proven.
59:
60:
61:
62: 9FRANZ LISP 1-1
63:
64:
65:
66:
67:
68:
69:
70: FRANZ LISP 1-2
71:
72:
73: arrays and exception handling. In the third Movement
74: we will look at several large support packages written
75: to help the FRANZ LISP user, namely the trace package,
76: compiler, fixit and stepping package. Finally the
77: fourth movement contains an index into the other
78: movements. In the rest of this chapter we shall exam-
79: ine the data types of FRANZ LISP. The conventions
80: used in the description of the FRANZ LISP functions
81: will be given in 1.3 -- it is very important that
82: these conventions are understood.
83:
84:
85:
86: 1.2. Data Types FRANZ LISP has fourteen data types.
87: In this section we shall look in detail at each type
88: and if a type is divisible we shall look inside it.
89: There is a Lisp function _t_y_p_e which will return the
90: type name of a lisp object. This is the official
91: FRANZ LISP name for that type and we will use this
92: name and this name only in the manual to avoid confus-
93: ing the reader. The types are listed in terms of
94: importance rather than alphabetically.
95:
96:
97:
98: 1.2.0. lispval This is the name we use to describe
99: any lisp object. The function _t_y_p_e will never
100: return `lispval'.
101:
102:
103:
104: 1.2.1. symbol This object corresponds to a variable
105: in most other programming languages. It may have a
106: value or may be `unbound'. A symbol may be _l_a_m_b_d_a
107: _b_o_u_n_d meaning that its current value is stored away
108: somewhere and the symbol is given a new value for
109: the duration of a certain context. When the Lisp
110: processor leaves that context, the symbol's
111: current value is thrown away and its old value is
112: restored.
113: 9 A symbol may also have a _f_u_n_c_t_i_o_n _b_i_n_d_i_n_g. This
114: function binding is static; it cannot be lambda
115: bound. Whenever the symbol is used in the func-
116: tional position of a Lisp expression the function
117: binding of the symbol is examined (see Chapter 4
118: for more details on evaluation).
119: 9 A symbol may also have a _p_r_o_p_e_r_t_y _l_i_s_t, another
120: static data structure. The property list consists
121: of a list of an even number of elements, considered
122: to be grouped as pairs. The first element of the
123: pair is the _i_n_d_i_c_a_t_o_r the second the _v_a_l_u_e of that
124: indicator.
125:
126:
127: Printed: August 5, 1983
128:
129:
130:
131:
132:
133:
134:
135: FRANZ LISP 1-3
136:
137:
138: Each symbol has a print name (_p_n_a_m_e) which is how
139: this symbol is accessed from input and referred to
140: on (printed) output.
141: 9 A symbol also has a hashlink used to link symbols
142: together in the oblist -- this field is inaccessi-
143: ble to the lisp user.
144: 9 Symbols are created by the reader and by the func-
145: tions _c_o_n_c_a_t, _m_a_k_n_a_m and their derivatives. Most
146: symbols live on FRANZ LISP's sole _o_b_l_i_s_t, and
147: therefore two symbols with the same print name are
148: usually the exact same object (they are _e_q). Sym-
149: bols which are not on the oblist are said to be
150: _u_n_i_n_t_e_r_n_e_d. The function _m_a_k_n_a_m creates uninterned
151: symbols while _c_o_n_c_a_t creates _i_n_t_e_r_n_e_d ones.
152:
153:
154: 8 ____________________________________________________________
155: Subpart name Get value Set value Type
156:
157: 8 ________________________________________________________________________________________________________________________
158: value eval set lispval
159: setq
160: 8 ____________________________________________________________
161: property plist setplist list or nil
162: list get putprop
163: defprop
164: 8 ____________________________________________________________
165: function getd putd array, binary, list
166: binding def or nil
167: 8 ____________________________________________________________
168: print name get_pname string
169: 8 ____________________________________________________________
170: hash link
171: 8 ____________________________________________________________
172: 7 |7|7|7|7|7|7|7|7|7|7|7|7|7|
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185: |7|7|7|7|7|7|7|7|7|7|7|7|7|
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198: |7|7|7|7|7|7|7|7|7|7|7|7|7|
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211: |7|7|7|7|7|7|7|7|7|7|7|7|7|
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224: |7|7|7|7|7|7|7|7|7|7|7|7|7|
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242: 1.2.2. list A list cell has two parts, called the
243: car and cdr. List cells are created by the func-
244: tion _c_o_n_s.
245:
246:
247: 8 ________________________________________________
248: Subpart name Get value Set value Type
249:
250: 8 ________________________________________________________________________________________________
251: car car rplaca lispval
252: 8 ________________________________________________
253: cdr cdr rplacd lispval
254: 8 ________________________________________________
255: 7 |8|7|7|7|7|
256:
257:
258:
259: 9 |8|7|7|7|7|
260:
261:
262:
263: 9 |8|7|7|7|7|
264:
265:
266:
267: 9 |8|7|7|7|7|
268:
269:
270:
271: 9 |8|7|7|7|7|
272:
273:
274:
275:
276:
277: 9
278:
279:
280:
281:
282:
283:
284: 9 Printed: August 5, 1983
285:
286:
287:
288:
289:
290:
291:
292: FRANZ LISP 1-4
293:
294:
295: 1.2.3. binary This type acts as a function header
296: for machine coded functions. It has two parts, a
297: pointer to the start of the function and a symbol
298: whose print name describes the argument _d_i_s_c_i_p_l_i_n_e.
299: The discipline (if _l_a_m_b_d_a, _m_a_c_r_o or _n_l_a_m_b_d_a) deter-
300: mines whether the arguments to this function will
301: be evaluated by the caller before this function is
302: called. If the discipline is a string (specifi-
303: cally "_s_u_b_r_o_u_t_i_n_e", "_f_u_n_c_t_i_o_n", "_i_n_t_e_g_e_r-_f_u_n_c_t_i_o_n",
304: "_r_e_a_l-_f_u_n_c_t_i_o_n", "_c-_f_u_n_c_t_i_o_n", "_d_o_u_b_l_e-_c-_f_u_n_c_t_i_o_n",
305: or "_v_e_c_t_o_r-_c-_f_u_n_c_t_i_o_n" ) then this function is a
306: foreign subroutine or function (see 8.5 for more
307: details on this). Although the type of the _e_n_t_r_y
308: field of a binary type object is usually string or
309: other, the object pointed to is actually a sequence
310: of machine instructions.
311: Objects of type binary are created by _m_f_u_n_c_t_i_o_n,
312: _c_f_a_s_l, and _g_e_t_a_d_d_r_e_s_s.
313:
314:
315: 8 _________________________________________________________
316: Subpart name Get value Set value Type
317:
318: 8 __________________________________________________________________________________________________________________
319: entry getentry string or fixnum
320: 8 _________________________________________________________
321: discipline getdisc putdisc symbol or fixnum
322: 8 _________________________________________________________
323: 7 |8|7|7|7|7|
324:
325:
326:
327: 9 |8|7|7|7|7|
328:
329:
330:
331: 9 |8|7|7|7|7|
332:
333:
334:
335: 9 |8|7|7|7|7|
336:
337:
338:
339: 9 |8|7|7|7|7|
340:
341:
342:
343:
344:
345: 9
346:
347:
348: 1.2.4. fixnum A fixnum is an integer constant in
349: the range -2[31] to 2[31]-1. Small fixnums (-1024
350: to 1023) are stored in a special table so they
351: needn't be allocated each time one is needed.
352:
353:
354:
355: 1.2.5. flonum A flonum is a double precision real
356: number in the range +_2.9x10[-37] to +_1.7x10[38].
357: There are approximately sixteen decimal digits of
358: precision.
359:
360:
361:
362: 1.2.6. bignum A bignum is an integer of potentially
363: unbounded size. When integer arithmetic exceeds
364: the limits of fixnums mentioned above, the calcula-
365: tion is automatically done with bignums. Should
366: calculation with bignums give a result which can be
367: represented as a fixnum, then the fixnum represen-
368:
369:
370: 9
371:
372: 9 Printed: August 5, 1983
373:
374:
375:
376:
377:
378:
379:
380: FRANZ LISP 1-5
381:
382:
383: tation will be used[]. This contraction is known
384: as _i_n_t_e_g_e_r _n_o_r_m_a_l_i_z_a_t_i_o_n. Many Lisp functions
385: assume that integers are normalized. Bignums are
386: composed of a sequence of list cells and a cell
387: known as an sdot. The user should consider a big-
388: num structure indivisible and use functions such as
389: _h_a_i_p_a_r_t, and _b_i_g_n_u_m-_l_e_f_t_s_h_i_f_t to extract parts of
390: it.
391:
392:
393:
394: 1.2.7. string A string is a null terminated
395: sequence of characters. Most functions of symbols
396: which operate on the symbol's print name will also
397: work on strings. The default reader syntax is set
398: so that a sequence of characters surrounded by dou-
399: ble quotes is a string.
400:
401:
402:
403: 1.2.8. port A port is a structure which the system
404: I/O routines can reference to transfer data between
405: the Lisp system and external media. Unlike other
406: Lisp objects there are a very limited number of
407: ports (20). Ports are allocated by _i_n_f_i_l_e and _o_u_t_-
408: _f_i_l_e and deallocated by _c_l_o_s_e and _r_e_s_e_t_i_o. The
409: _p_r_i_n_t function prints a port as a percent sign fol-
410: lowed by the name of the file it is connected to
411: (if the port was opened by _f_i_l_e_o_p_e_n, _i_n_f_i_l_e, _o_r
412: _o_u_t_f_i_l_e). During initialization, FRANZ LISP binds
413: the symbol piport to a port attached to the stan-
414: dard input stream. This port prints as %$stdin.
415: There are ports connected to the standard output
416: and error streams, which print as %$stdout and
417: %$stderr. This is discussed in more detail at the
418: beginning of Chapter 5.
419:
420:
421:
422: 1.2.9. vector Vectors are indexed sequences of
423: data. They can be used to implement a notion of
424: user-defined types, via their associated property
425: list. They make hunks (see below) logically
426: unnecessary, although hunks are very efficiently
427: garbage collected. There is a second kind of vec-
428: tor, called an immediate-vector, which stores
429: binary data. The name that the function _t_y_p_e
430: ____________________
431: 9 []The current algorithms for integer arithmetic opera-
432: tions will return (in certain cases) a result between +_2[30]
433: and 2[31] as a bignum although this could be represented as
434: a fixnum.
435:
436:
437: 9 Printed: August 5, 1983
438:
439:
440:
441:
442:
443:
444:
445: FRANZ LISP 1-6
446:
447:
448: returns for immediate-vectors is vectori.
449: Immediate-vectors could be used to implement
450: strings and block-flonum arrays, for example. Vec-
451: tors are discussed in chapter 9. The functions
452: _n_e_w-_v_e_c_t_o_r, and _v_e_c_t_o_r, can be used to create vec-
453: tors.
454:
455:
456: 8 ________________________________________________
457: Subpart name Get value Set value Type
458:
459: 8 ________________________________________________________________________________________________
460: datum[_i] vref vset lispval
461: 8 ________________________________________________
462: property vprop vsetprop lispval
463: vputprop
464: 8 ________________________________________________
465: size vsize - fixnum
466: 8 ________________________________________________
467: 7 |7|7|7|7|7|7|7|
468:
469:
470:
471:
472:
473:
474: |7|7|7|7|7|7|7|
475:
476:
477:
478:
479:
480:
481: |7|7|7|7|7|7|7|
482:
483:
484:
485:
486:
487:
488: |7|7|7|7|7|7|7|
489:
490:
491:
492:
493:
494:
495: |7|7|7|7|7|7|7|
496:
497:
498:
499:
500:
501:
502:
503:
504:
505:
506:
507: 1.2.10. array Arrays are rather complicated types
508: and are fully described in Chapter 9. An array
509: consists of a block of contiguous data, a function
510: to access that data and auxiliary fields for use by
511: the accessing function. Since an array's accessing
512: function is created by the user, an array can have
513: any form the user chooses (e.g. n-dimensional, tri-
514: angular, or hash table).
515: Arrays are created by the function _m_a_r_r_a_y.
516:
517:
518: 8 _______________________________________________________________
519: Subpart name Get value Set value Type
520:
521: 8 ______________________________________________________________________________________________________________________________
522: access function getaccess putaccess binary, list
523: or symbol
524: 8 _______________________________________________________________
525: auxiliary getaux putaux lispval
526: 8 _______________________________________________________________
527: data arrayref replace block of contiguous
528: set lispval
529: 8 _______________________________________________________________
530: length getlength putlength fixnum
531: 8 _______________________________________________________________
532: delta getdelta putdelta fixnum
533: 8 _______________________________________________________________
534: 7 |7|7|7|7|7|7|7|7|7|7|7|
535:
536:
537:
538:
539:
540:
541:
542:
543:
544:
545: |7|7|7|7|7|7|7|7|7|7|7|
546:
547:
548:
549:
550:
551:
552:
553:
554:
555:
556: |7|7|7|7|7|7|7|7|7|7|7|
557:
558:
559:
560:
561:
562:
563:
564:
565:
566:
567: |7|7|7|7|7|7|7|7|7|7|7|
568:
569:
570:
571:
572:
573:
574:
575:
576:
577:
578: |7|7|7|7|7|7|7|7|7|7|7|
579:
580:
581:
582:
583:
584:
585:
586:
587:
588:
589:
590:
591:
592:
593:
594: 1.2.11. value A value cell contains a pointer to a
595: lispval. This type is used mainly by arrays of
596: general lisp objects. Value cells are created with
597: the _p_t_r function. A value cell containing a
598: pointer to the symbol `foo' is printed as
599:
600:
601: Printed: August 5, 1983
602:
603:
604:
605:
606:
607:
608:
609: FRANZ LISP 1-7
610:
611:
612: `(ptr to)foo'
613:
614:
615:
616: 1.2.12. hunk A hunk is a vector of from 1 to 128
617: lispvals. Once a hunk is created (by _h_u_n_k or
618: _m_a_k_h_u_n_k) it cannot grow or shrink. The access time
619: for an element of a hunk is slower than a list cell
620: element but faster than an array. Hunks are really
621: only allocated in sizes which are powers of two,
622: but can appear to the user to be any size in the 1
623: to 128 range. Users of hunks must realize that
624: (_n_o_t (_a_t_o_m '_l_i_s_p_v_a_l)) will return true if _l_i_s_p_v_a_l
625: is a hunk. Most lisp systems do not have a direct
626: test for a list cell and instead use the above test
627: and assume that a true result means _l_i_s_p_v_a_l is a
628: list cell. In FRANZ LISP you can use _d_t_p_r to check
629: for a list cell. Although hunks are not list
630: cells, you can still access the first two hunk ele-
631: ments with _c_d_r and _c_a_r and you can access any hunk
632: element with _c_x_r[]. You can set the value of the
633: first two elements of a hunk with _r_p_l_a_c_d and _r_p_l_a_c_a
634: and you can set the value of any element of the
635: hunk with _r_p_l_a_c_x. A hunk is printed by printing
636: its contents surrounded by { and }. However a hunk
637: cannot be read in in this way in the standard lisp
638: system. It is easy to write a reader macro to do
639: this if desired.
640:
641:
642:
643: 1.2.13. other Occasionally, you can obtain a
644: pointer to storage not allocated by the lisp sys-
645: tem. One example of this is the entry field of
646: those FRANZ LISP functions written in C. Such
647: objects are classified as of type other. Foreign
648: functions which call malloc to allocate their own
649: space, may also inadvertantly create such objects.
650: The garbage collector is supposed to ignore such
651: objects.
652:
653:
654:
655: 1.3. Documentation The conventions used in the follow-
656: ing chapters were designed to give a great deal of
657: information in a brief space. The first line of a
658: function description contains the function name in
659: bold face and then lists the arguments, if any. The
660: ____________________
661: 9 []In a hunk, the function _c_d_r references the first ele-
662: ment and _c_a_r the second.
663:
664:
665:
666: 9 Printed: August 5, 1983
667:
668:
669:
670:
671:
672:
673:
674: FRANZ LISP 1-8
675:
676:
677: arguments all have names which begin with a letter or
678: letters and an underscore. The letter(s) gives the
679: allowable type(s) for that argument according to this
680: table.
681:
682:
683: 8 _______________________________________________________
684: Letter Allowable type(s)
685:
686: 8 ______________________________________________________________________________________________________________
687: g any type
688: 8 _______________________________________________________
689: s symbol (although nil may not be allowed)
690: 8 _______________________________________________________
691: t string
692: 8 _______________________________________________________
693: l list (although nil may be allowed)
694: 8 _______________________________________________________
695: n number (fixnum, flonum, bignum)
696: 8 _______________________________________________________
697: i integer (fixnum, bignum)
698: 8 _______________________________________________________
699: x fixnum
700: 8 _______________________________________________________
701: b bignum
702: 8 _______________________________________________________
703: f flonum
704: 8 _______________________________________________________
705: u function type (either binary or lambda body)
706: 8 _______________________________________________________
707: y binary
708: 8 _______________________________________________________
709: v vector
710: 8 _______________________________________________________
711: V vectori
712: 8 _______________________________________________________
713: a array
714: 8 _______________________________________________________
715: e value
716: 8 _______________________________________________________
717: p port (or nil)
718: 8 _______________________________________________________
719: h hunk
720: 8 _______________________________________________________
721: 7 |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|
722:
723:
724:
725:
726:
727:
728:
729:
730:
731:
732:
733:
734:
735:
736:
737:
738:
739:
740:
741:
742:
743:
744:
745:
746:
747:
748: |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|
749:
750:
751:
752:
753:
754:
755:
756:
757:
758:
759:
760:
761:
762:
763:
764:
765:
766:
767:
768:
769:
770:
771:
772:
773:
774:
775: |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|
776:
777:
778:
779:
780:
781:
782:
783:
784:
785:
786:
787:
788:
789:
790:
791:
792:
793:
794:
795:
796:
797:
798:
799:
800:
801:
802:
803:
804:
805: In the first line of a function description, those
806: arguments preceded by a quote mark are evaluated (usu-
807: ally before the function is called). The quoting con-
808: vention is used so that we can give a name to the
809: result of evaluating the argument and we can describe
810: the allowable types. If an argument is not quoted it
811: does not mean that that argument will not be
812: evaluated, but rather that if it is evaluated, the
813: time at which it is evaluated will be specifically
814: mentioned in the function description. Optional argu-
815: ments are surrounded by square brackets. An ellipsis
816: (...) means zero or more occurrences of an argument of
817: the directly preceding type.
818:
819:
820:
821:
822:
823: 9 Printed: August 5, 1983
824:
825:
826:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.