Commit | Line | Data |
---|---|---|
17ce9497 C |
1 | ." $Header: /na/franz/doc/RCS/ch1.n,v 1.1 83/01/31 07:07:16 jkf Exp $ |
2 | .Lc \s+2F\s-2RANZ\s0\ L\s-2ISP\s0\s-2 1 | |
3 | .sh 2 | |
4 | .Fr \*[\(dg\*] | |
5 | was created as a tool to further research in symbolic and | |
6 | algebraic manipulation, | |
7 | artificial intelligence, | |
8 | and programming languages at the University of California | |
9 | at Berkeley. | |
10 | .(f | |
11 | \*[\(dg\*]It is rumored that this name has something to do with Franz | |
12 | Liszt [F\fIr\fPa\*:nts List] (1811-1886) a Hungarian composer | |
13 | and keyboard virtuoso. | |
14 | These allegations have never been proven. | |
15 | .)f | |
16 | Its roots are in the PDP-11 Lisp system which originally came | |
17 | from Harvard. | |
18 | As it grew it adopted features of Maclisp and Lisp Machine Lisp | |
19 | which enables our work to be shared with colleagues at | |
20 | the Laboratory for Computer Science at M.I.T. | |
21 | Substantial compatibility with other Lisp dialects | |
22 | (Interlisp, UCILisp, CMULisp) is achieved by | |
23 | means of support packages and compiler switches. | |
24 | .Fr | |
25 | is written almost entirely in the programming language C. | |
26 | A small part is written in the assembler language for the current | |
27 | host machine, a VAX 11/780, and part is written in Lisp. | |
28 | Because | |
29 | .Fr | |
30 | is written in C, it is relatively portable and easy to comprehend. | |
31 | .pp | |
32 | .Fr | |
33 | is capable of running large lisp programs in a timesharing environment, | |
34 | has facilities for arrays and user defined structures, | |
35 | has a user controlled reader with character and word macro capabilities, | |
36 | and can interact directly with compiled Lisp, C, Fortran, and Pascal code. | |
37 | .pp | |
38 | This document is a reference manual for the | |
39 | .Fr | |
40 | system. | |
41 | It is not a Lisp primer or introduction to the language. | |
42 | Some parts will be of interest only to those maintaining | |
43 | .Fr | |
44 | at their computer site. | |
45 | This document is divided into four Movements. | |
46 | In the first one we will attempt to describe the language of | |
47 | .Fr | |
48 | precisely and completely as it now stands (Opus 38, April 1982). | |
49 | In the second Movement we will look at the reader, function types, | |
50 | arrays and exception handling. | |
51 | In the third Movement we will look at several large support packages | |
52 | written to help the | |
53 | .Fr | |
54 | user, namely the trace package, compiler, fixit and stepping package. | |
55 | Finally the fourth movement contains an index into the other movements. | |
56 | In the rest of this chapter we shall examine the data types of | |
57 | .Fr . | |
58 | The conventions used in the description of the | |
59 | .Fr | |
60 | functions will be given in section 1.4 -- it is very important that | |
61 | these conventions are understood. | |
62 | .sh 2 Data\ Types | |
63 | .Fr | |
64 | has eleven data types. | |
65 | In this section we shall look in detail at each type and if a type is | |
66 | divisible we shall look inside it. | |
67 | There is a Lisp function | |
68 | .i type | |
69 | which will return the type name of a lisp object. | |
70 | This is the official | |
71 | .Fr | |
72 | name for that type and we will use this name and this name only in | |
73 | the manual to avoid confusing the reader. | |
74 | The types are listed in terms of importance rather than alphabetically. | |
75 | .sh 3 lispval - - 0 | |
76 | This is the name we use to describe any lisp object. | |
77 | The function | |
78 | .i type | |
79 | will never return `lispval'. | |
80 | .sh 3 symbol | |
81 | This object corresponds to a variable in most other programming languages. | |
82 | It may have a value or may be `unbound'. | |
83 | A symbol may be | |
84 | .i lambda | |
85 | .i bound | |
86 | meaning that its current value is stored | |
87 | away somewhere and the symbol is given a new value for the duration of a | |
88 | certain context. | |
89 | When the Lisp processor leaves that context, the | |
90 | symbol's current value is thrown | |
91 | away and its old value is restored. | |
92 | .sp .5v | |
93 | A symbol may also have a | |
94 | .i function | |
95 | .i binding . | |
96 | This function binding is static; it cannot be lambda bound. | |
97 | Whenever the symbol is used in the functional position of a Lisp expression | |
98 | the function binding of the symbol is examined (see Chapter 4 for more | |
99 | details on evaluation). | |
100 | .sp .5v | |
101 | A symbol may also have a | |
102 | .i property | |
103 | .i list , | |
104 | another static data structure. | |
105 | The property list consists of a list of an even number of elements, | |
106 | considered to be grouped as pairs. | |
107 | The first element of the pair is the | |
108 | .i indicator | |
109 | the second the | |
110 | .i value | |
111 | of that indicator. | |
112 | .sp .5v | |
113 | Each symbol has a print name | |
114 | .i (pname) | |
115 | which is how this symbol is accessed from input and referred to | |
116 | on (printed) output. | |
117 | .sp .5v | |
118 | A symbol also has a hashlink used to link symbols together in the | |
119 | oblist -- this field is inaccessible to the lisp user. | |
120 | .sp .5v | |
121 | Symbols are created by the reader and by the functions | |
122 | .i concat , | |
123 | .i maknam | |
124 | and their derivatives. | |
125 | Most symbols live on | |
126 | .Fr 's | |
127 | sole | |
128 | .i oblist , | |
129 | and therefore two symbols with the same print name are | |
130 | usually the exact same object (they are | |
131 | .i eq ). | |
132 | Symbols which are not on the oblist are said to be | |
133 | .i uninterned. | |
134 | The function | |
135 | .i maknam | |
136 | creates uninterned symbols while | |
137 | .i concat | |
138 | creates | |
139 | .i interned | |
140 | ones. | |
141 | .sp 1v | |
142 | .TS | |
143 | box center ; | |
144 | c | c | c | c . | |
145 | Subpart name Get value Set value Type | |
146 | ||
147 | = | |
148 | value eval set lispval | |
149 | setq | |
150 | _ | |
151 | property plist setplist list or nil | |
152 | list get putprop | |
153 | _ | |
154 | function getd putd array, binary, list | |
155 | binding def or nil | |
156 | _ | |
157 | print name get_pname string | |
158 | _ | |
159 | hash link | |
160 | .TE | |
161 | .sh 3 list | |
162 | A list cell has two parts, called the car and cdr. | |
163 | List cells are created by the function | |
164 | .i cons . | |
165 | .sp 1v | |
166 | .TS | |
167 | box center ; | |
168 | c | c | c | c . | |
169 | Subpart name Get value Set value Type | |
170 | ||
171 | = | |
172 | car car rplaca lispval | |
173 | _ | |
174 | cdr cdr rplacd lispval | |
175 | .TE | |
176 | .sh 3 binary | |
177 | This type acts as a function header for machine coded functions. | |
178 | It has two parts, a pointer to the start of the function and a | |
179 | symbol whose print name describes the | |
180 | argument | |
181 | .i discipline . | |
182 | The discipline (if | |
183 | .i lambda , | |
184 | .i macro | |
185 | or | |
186 | .i nlambda ) | |
187 | determines whether the arguments to this function will be evaluated | |
188 | by the caller | |
189 | before this function is called. | |
190 | If the discipline is a string (either | |
191 | "\fIsubroutine\fP", | |
192 | "\fIfunction\fP", | |
193 | "\fIinteger-function\fP", | |
194 | or | |
195 | "\fIreal-function\fP") | |
196 | then this function is | |
197 | a foreign subroutine or function (see \(sc8.4 for more details on this). | |
198 | Although the type of the | |
199 | .i entry | |
200 | field of a binary type object is either string or fixnum, | |
201 | the object pointed to | |
202 | is actually a sequence of machine instructions. | |
203 | .br | |
204 | Objects of type binary are created by | |
205 | .i mfunction . | |
206 | .sp 1v | |
207 | .TS | |
208 | box center ; | |
209 | c | c | c | c . | |
210 | Subpart name Get value Set value Type | |
211 | ||
212 | = | |
213 | entry getentry string or fixnum | |
214 | _ | |
215 | discipline getdisc putdisc symbol or fixnum | |
216 | .TE | |
217 | .sh 3 fixnum | |
218 | A fixnum is an integer constant in the range \(mi2\*[31\*] to | |
219 | 2\*[31\*]\(mi1. | |
220 | Small fixnums (-1024 to 1023) are stored in a special table so they needn't be | |
221 | allocated each time one is needed. | |
222 | .sh 3 flonum | |
223 | A flonum is a double precision real number in the range | |
224 | \(+-2.9\(mu10\*[-37\*] to \(+-1.7\(mu10\*[38\*]. | |
225 | There are approximately sixteen decimal digits of precision. | |
226 | .sh 3 bignum | |
227 | A bignum is an integer of potentially unbounded size. | |
228 | When integer arithmetic exceeds the limits mentioned above the calculation | |
229 | is automatically done with bignums. | |
230 | Should calculation with bignums give a result which can be represented | |
231 | as a fixnum, then the fixnum representation will be used\*[\(dg\*]. | |
232 | .(f | |
233 | \*[\(dg\*]The current algorithms for integer arithmetic operations will return | |
234 | (in certain cases) a result | |
235 | between \(+-2\*[30\*] and 2\*[31\*] as a bignum although this | |
236 | could be represented as a fixnum. | |
237 | .)f | |
238 | This contraction is known as | |
239 | .i integer | |
240 | .i normalization . | |
241 | Many Lisp functions assume that integers are normalized. | |
242 | Bignums are composed of a sequence of | |
243 | .b list | |
244 | cells and a cell known as an | |
245 | .b sdot. | |
246 | The user should consider a | |
247 | .b bignum | |
248 | structure indivisible and use functions such as | |
249 | .i haipart , | |
250 | and | |
251 | .i bignum-leftshift | |
252 | to extract parts of it. | |
253 | .sh 3 string | |
254 | A string is a null terminated sequence of characters. | |
255 | Most functions of symbols which operate on the symbol's print name will | |
256 | also work on strings. | |
257 | The default reader syntax is set so that | |
258 | a sequence of characters surrounded by double quotes is a string. | |
259 | .sh 3 port | |
260 | A port is a structure which the system I/O routines can reference to | |
261 | transfer data between the Lisp system and external media. | |
262 | Unlike other Lisp objects there are a very limited number of ports (20). | |
263 | Ports are allocated by | |
264 | .i infile | |
265 | and | |
266 | .i outfile | |
267 | and deallocated by | |
268 | .i close | |
269 | and | |
270 | .i resetio . | |
271 | The | |
272 | .i print | |
273 | function prints a port as a percent sign followed by the name of the file it | |
274 | is connected to. | |
275 | The file names $stdin, $stdout and $stderr refer to the standard input, | |
276 | output and error files. | |
277 | .sh 3 array | |
278 | Arrays are rather complicated types and are fully described in | |
279 | Chapter 9. | |
280 | An array consists of a block of contiguous data, a function | |
281 | to access that data and auxiliary fields for use by the accessing | |
282 | function. | |
283 | Since an array's accessing function is created by the user, an array can | |
284 | have any form the user chooses (e.g. n-dimensional, triangular, or hash | |
285 | table). | |
286 | .br | |
287 | Arrays are created by the function | |
288 | .i marray . | |
289 | .sp 1v | |
290 | .TS | |
291 | box center ; | |
292 | c | c | c | c . | |
293 | Subpart name Get value Set value Type | |
294 | ||
295 | = | |
296 | access function getaccess putaccess binary, list | |
297 | or symbol | |
298 | _ | |
299 | auxiliary getaux putaux lispval | |
300 | _ | |
301 | data arrayref replace block of contiguous | |
302 | set lispval | |
303 | _ | |
304 | length getlength putlength fixnum | |
305 | _ | |
306 | delta getdelta putdelta fixnum | |
307 | .TE | |
308 | .sh 3 value | |
309 | A value cell contains a pointer to a lispval. | |
310 | This type is used mainly by arrays of general lisp objects. | |
311 | Value cells are created with the | |
312 | .i ptr | |
313 | function. | |
314 | A value cell containing a pointer to the symbol `foo' is printed | |
315 | as `(ptr\ to)foo' | |
316 | .sh 3 hunk | |
317 | A hunk is a vector of from 1 to 128 lispvals. | |
318 | Once a hunk is created (by | |
319 | .i hunk | |
320 | or | |
321 | .i makhunk ) | |
322 | it cannot grow or shrink. | |
323 | The access time for an element of a hunk is slower than a list cell element | |
324 | but faster than an array. | |
325 | Hunks are really only allocated in sizes which are powers of two, but | |
326 | can appear to the user to be any size in the 1 to 128 range. | |
327 | Users of hunks must realize that \fI(not\ (atom\ 'lispval))\fP | |
328 | will return true if | |
329 | .i lispval | |
330 | is a hunk. | |
331 | Most lisp systems do not have a direct test for a list cell and instead use | |
332 | the above test and assume that | |
333 | a true result means | |
334 | .i lispval | |
335 | is a list cell. | |
336 | In | |
337 | .Fr | |
338 | you can use | |
339 | .i dtpr | |
340 | to check for a list cell. | |
341 | Although hunks are not list cells, you can still access the first two | |
342 | hunk elements with | |
343 | .i cdr | |
344 | and | |
345 | .i car | |
346 | and you can access any hunk element with | |
347 | .i cxr \*[\(dg\*]. | |
348 | .(f | |
349 | \*[\(dg\*]In a hunk, the function | |
350 | .i cdr | |
351 | references the first element | |
352 | and | |
353 | .i car | |
354 | the second. | |
355 | .)f | |
356 | You can set the value of the first two elements of a hunk with | |
357 | .i rplacd | |
358 | and | |
359 | .i rplaca | |
360 | and you can set the value of any element of the hunk with | |
361 | .i rplacx . | |
362 | A hunk is printed by printing its contents surrounded by { and }. | |
363 | However a hunk cannot be read in in this way in the standard lisp system. | |
364 | It is easy to write a reader macro to do this if desired. | |
365 | .sh 2 Documentation Conventions. | |
366 | The conventions used in the following chapters were designed to | |
367 | give a great deal of information in a brief | |
368 | space. | |
369 | The first line of a function description contains the function | |
370 | name in \fBbold\ face\fP and then lists the arguments, if any. | |
371 | The arguments all have names which begin with a letter or letters and | |
372 | an underscore. | |
373 | The letter(s) gives the allowable type(s) for that argument according to | |
374 | this table. | |
375 | .sp 1v | |
376 | .TS | |
377 | box center ; | |
378 | c | c | |
379 | l | l . | |
380 | Letter Allowable type(s) | |
381 | ||
382 | = | |
383 | g any type | |
384 | _ | |
385 | s symbol (although nil may not be allowed) | |
386 | _ | |
387 | t string | |
388 | _ | |
389 | l list (although nil may be allowed) | |
390 | _ | |
391 | n number (fixnum, flonum, bignum) | |
392 | _ | |
393 | i integer (fixnum, bignum) | |
394 | _ | |
395 | x fixnum | |
396 | _ | |
397 | b bignum | |
398 | _ | |
399 | f flonum | |
400 | _ | |
401 | u function type (either binary or lambda body) | |
402 | _ | |
403 | y binary | |
404 | _ | |
405 | a array | |
406 | _ | |
407 | v value | |
408 | _ | |
409 | p port (or nil) | |
410 | _ | |
411 | h hunk | |
412 | .TE | |
413 | ||
414 | In the first line of a function description, | |
415 | those arguments preceded by a quote mark are evaluated (usually | |
416 | before the function is called). | |
417 | The quoting convention is used so that we can give a name to the result of | |
418 | evaluating the argument and we can describe the allowable types. | |
419 | If an argument is not quoted it does not mean that that argument will | |
420 | not be evaluated, but rather that | |
421 | if it is evaluated, the time at which it is evaluated | |
422 | will be specifically mentioned in the function description. | |
423 | Optional arguments are surrounded by square brackets. | |
424 | An ellipsis means zero or more occurrences of an argument of the | |
425 | directly preceding | |
426 | type. |