Page Numbers: Yes X: 306 Y: 1.0" First Page: 40
Margins: Top: 1.0" Bottom: 1.3"
Heading:
STANDARD PROCEDURE GUIDE3-LISP REFERENCE MANUALJanuary 25, 1983
————————————————
9. Standard Procedure Guide
————————————————
Notes:
1.Each procedure is illustrated with non-objectified arguments, but many can be used in other ways (for example: (PCONS . (REST ’[A B C])) g ’(B . C)).
2.For each function, we give the declarative import. In many cases that is the only semantical information provided, since if the designation has a canonical normal-form designator, what is returned can be determined from this designation in conjunction with the normal-form theorem. For example, since (+ 2 3) designates the number 5, it will return the numeral 5; since (= ’A ’B) designates falsity, it will return the boolean $F. If, however, the normal-form designator is not canonical, or if there are side effects, the relevant parts of the procedural significance are described as well.
3.Typing information is typically given only in terms of what we call the functions "F-type". Thus for example the division function / would be said to have F-type of [NUMBERSXNUMBERS] NUMBERS. In some cases, the typing restrictions specified in this section are stricter than one would expect given the section 8 definitions. At some point in time, the code will be tightened up (once a theory of errors is in place).
4.The semantic equations use the following meta-theoretic utility functions:
...
5.Underlined arguments in the title line of a procedure description indicate those positions that are normalised tail recursively with respect to the procedure call (e.g., the 2nd and 3rd arguments to IF).
6.Several one-word attributes are associated with each procedure that can provide a quick reference for determining the nature of the procedure. The following keywords are used:
ConsThis procedure may create new structures that will be accessible from the result.
SmashInternal structures accessible from the argument designators may be smashed (with REPLACE).
EnvSome of the arguments to this procedure may be normalised in some environment other that the current one; however, these environment manipulations are accomplished through non-destructive means.
Smash-envThis procedure may destructively change the current environment.
I/OThis procedure may side effect the outside world by doing I/O.
CPSThis procedure is written in the continuation-passing style — instead of returning, the result is explicitly passed to the continuation (one of the arguments).
AbnormalSome of the arguments may not always be normalised.
7.Still other keywords are used to indicate the nature of the procedure’s status within the implementation:
PrimitiveThis procedure is one of the 30 or so primitives that have only viciously circular definitions within the 3-LISP system. All non-primitive have complete and accurate descriptions in terms of the primitives.
ProtectedBoth the closure for this procedure, its pattern and body, and its binding within the global environment are protected from REPLACE. Unprotected procedures may be tampered with without risking toppling the reflective tower; nevertheless, smashing system procedures may have unpleasant consequences.
KernelThis procedure is an essential part of 3-LISP because it is used regularly by the reflective processors at all levels.
————————————————————————————————————————————
9.a. PAIRS
————————————————————————————————————————————
(PCONS S1 S2)
Designates an otherwise inaccessible pair whose CAR is the internal structure designated by S1 and whose CDR is the internal structure designated by S2.
Properties:Primitive; protected; cons.
F-Type:[STRUCTURES X STRUCTURES] PAIRS
Examples:(PCONS ’A ’B)g’(A . B)
(PCONS ’+ ’[2 3])g’(+ 2 3)
(PCONS 2 3)g{ERROR: Structure expected.}
Semantics:S(E0("PCONS),E,F,C) = l ...
———————————————————
(CAR PAIR)
Designates the internal structure that is the CAR of the pair designated by PAIR.
Properties:Primitive; protected; kernel.
F-Type:[ PAIRS ] STRUCTURES
Examples:(CAR ’(A . B))g’A
(CAR ’(1 . $T))
g’1
(CAR ’(+ 2 3))
g’+
(CAR ’+))
g{ERROR: Pair expected.}
Semantics:S(E0("CAR),E,F,C) = l ...
———————————————————
(CDR PAIR)
Designates the internal structure that is the CDR of the pair designated by PAIR.
Properties:Primitive; protected; kernel.
F-Type:[ PAIRS ] STRUCTURES
Examples:(CDR ’(A . B))g’B
(CAR ’(1 . $T))
g’$T
(CDR ’(+ 2 3))
g’[2 3]
(CDR ’(ACONS))
g’[]
(CDR ’1))
g{ERROR: Pair expected.}
Semantics:S(E0("CDR),E,F,C) = l ...
———————————————————
(XCONS S1 S2 ... Sk)
Designates an otherwise inaccessible pair whose CAR is the internal structure designated by S1 and whose CDR is an otherwise completely inaccessible rail whose elements are the internal structures designated by S2 through Sk (K > 1).
Properties:Cons.
F-Type:[ STRUCTURES X {STRUCTURES}* ] PAIRS
Examples:(XCONS ’+ ’2 ’3)g’(+ 2 3)
(XCONS ’ACONS)g’(ACONS)
(XCONS 1 2 3)
g{ERROR: Structure expected.}
Semantics:S(E0("XCONS),E,F,C) = l ...
————————————————————————————————————————————
9.b. RAILS and SEQUENCES
————————————————————————————————————————————
(RCONS S1 ... Sk)
Designates an otherwise completely inaccessible rail of length k whose elements are the internal structures designated by S1 through Sk (k>𔁆).
Properties:Primitive; protected; kernel; cons.
F-Type:[ {STRUCTURES}* ] RAILS
Examples:(RCONS ’1 ’2 ’3)g’[1 2 3]
(RCONS ’A (PCONS ’B ’C))g’[A (B . C)]
(RCONS)g’[]
(= (RCONS) (RCONS))g$F
(=
(RCONS) (RCONS))g$T
(RCONS 1 2 3)
g{ERROR: Structure expected.}
Semantics:S(E0("RCONS),E,F,C) = l ...
———————————————————
(SCONS E1 ... Ek)
Designates the sequence of length k of objects (internal or external) designated by E1 through Ek (k>𔁆); returns an otherwise completely inaccessible normal-form designator (rail) of that sequence. Note that sequence identity is as in mathematics: two sequences are the same if and only if they consist of the same elements in the same order.
Properties:Primitive; protected; kernel; cons.
F-Type:[ {OBJECTS}* ] SEQUENCES
Examples:(SCONS 1 2 3)g[1 2 3]
(SCONS ’1 ’2 ’3)
g[’1 ’2 ’3]
(SCONS ’A (+ 2 2))
g[’A 4]
[’A (+ 2 2)]
g[’A 4]
(SCONS)g[]
(= (SCONS) (SCONS))g$T
(= ↑(SCONS) ↑(SCONS))g$F
(LET [[X [1 2]]] (= X (SCONS . X)))g$T
(LET [[X [1 2]]] (= ↑X ↑(SCONS . X)))g$F
Semantics:S(E0("SCONS),E,F,C) = l ...
———————————————————
(PREP E VEC)
Designates a vector (of the same type as that designated by VEC) whose first element is the entity designated by E, and whose rest (i.e., first tail) is the vector designated by VEC. In case (PREP E VEC) designates a sequence, it returns an otherwise inaccessible rail whose first tail is the same rail as that to which VEC normalises (i.e., it returns an inaccessible but not completely inaccessible rail). Note that ‘PREP’ — short for ‘prepend’ — is pronounced in a way that connotes alligators.
Properties:Primitive; protected; kernel; cons.
F-Types:[ OBJECTS X SEQUENCES ] SEQUENCES
[ STRUCTURES X RAILS ] RAILS
Examples:(PREP 10 [20 30])g[10 20 30]
(PREP ’A ’[B C])g’[A B C]
(PREP #S "pain")
g"Spain"
(PREP [$T] [$F])
g[[$T] $F]
(PREP 10 ’[20 30])
g{ERROR: Structure expected.}
(PREP ’10 [20 30])
g[’10 20 30]
(PREP 1 2)
g{ERROR: Vector expected.}
Semantics:S(E0("PREP),E,F,C) = l ...