beowulf.host
provides Lisp 1.5 functions which can’t be (or can’t efficiently be) implemented in Lisp 1.5, which therefore need to be implemented in the host language, in this case Clojure.
AND
(AND & args)
T
if and only if none of my args
evaluate to either F
or NIL
, else F
.
In beowulf.host
principally because I don’t yet feel confident to define varargs functions in Lisp.
ASSOC
(ASSOC x a)
If a is an association list such as the one formed by PAIRLIS in the above example, then assoc will produce the first pair whose first term is x. Thus it is a table searching function.
All args are assumed to be beowulf.cons-cell/ConsCell
objects. See page 12 of the Lisp 1.5 Programmers Manual.
ATOM
(ATOM x)
Returns T
if and only if the argument x
is bound to an atom; else F
. It is not clear to me from the documentation whether (ATOM 7)
should return T
or F
. I’m going to assume T
.
ATOM?
macro
(ATOM? x)
The convention of returning F
from predicates, rather than NIL
, is going to tie me in knots. This is a variant of ATOM
which returns NIL
on failure.
CAR
(CAR x)
Return the item indicated by the first pointer of a pair. NIL is treated specially: the CAR of NIL is NIL.
CDR
(CDR x)
Return the item indicated by the second pointer of a pair. NIL is treated specially: the CDR of NIL is NIL.
DEFINE
(DEFINE args)
Bootstrap-only version of DEFINE
which, post boostrap, can be overwritten in LISP.
The single argument to DEFINE
should be an assoc list which should be nconc’ed onto the front of the oblist. Broadly, (SETQ OBLIST (NCONC ARG1 OBLIST))
EQUAL
(EQUAL x y)
This is a predicate that is true if its two arguments are identical S-expressions, and false if they are different. (The elementary predicate EQ
is defined only for atomic arguments.) The definition of EQUAL
is an example of a conditional expression inside a conditional expression.
NOTE: returns F
on failure, not NIL
lax?
(lax? symbol)
Are we in lax mode? If so. return true; is not, throw an exception with this symbol
.
OBLIST
(OBLIST)
Return a list of the symbols currently bound on the object list.
NOTE THAT in the Lisp 1.5 manual, footnote at the bottom of page 69, it implies that an argument can be passed but I’m not sure of the semantics of this.
PAIRLIS
(PAIRLIS x y a)
This function gives the list of pairs of corresponding elements of the lists x
and y
, and APPENDs this to the list a
. The resultant list of pairs, which is like a table with two columns, is called an association list.
Eessentially, it builds the environment on the stack, implementing shallow binding.
All args are assumed to be beowulf.cons-cell/ConsCell
objects. See page 12 of the Lisp 1.5 Programmers Manual.
QUOTIENT
(QUOTIENT x y)
I’m not certain from the documentation whether Lisp 1.5 QUOTIENT
returned the integer part of the quotient, or a realnum representing the whole quotient. I am for now implementing the latter.
RPLACA
(RPLACA cell value)
Replace the CAR pointer of this cell
with this value
. Dangerous, should really not exist, but does in Lisp 1.5 (and was important for some performance hacks in early Lisps)
RPLACD
(RPLACD cell value)
Replace the CDR pointer of this cell
with this value
. Dangerous, should really not exist, but does in Lisp 1.5 (and was important for some performance hacks in early Lisps)
SET
(SET symbol val)
Implementation of SET in Clojure. Add to the oblist
a binding of the value of var
to the value of val
. NOTE WELL: this is not SETQ!
SUBLIS
(SUBLIS a y)
Here a
is assumed to be an association list of the form ((ul . vl)...(un . vn))
, where the u
s are atomic, and y
is any S-expression. What SUBLIS
does, is to treat the u
s as variables when they occur in y
, and to SUBSTitute the corresponding v
s from the pair list.
My interpretation is that this is variable binding in the stack frame.
All args are assumed to be beowulf.cons-cell/ConsCell
objects. See page 12 of the Lisp 1.5 Programmers Manual.
SUBST
(SUBST x y z)
This function gives the result of substituting the S-expression x
for all occurrences of the atomic symbol y
in the S-expression z
.
TRACE
(TRACE s)
Add this symbol s
to the set of symbols currently being traced. If s
is not a symbol, does nothing.
uaf
(uaf l path)
Universal access function; l
is expected to be an arbitrary LISP list, path
a (clojure) list of the characters a
and d
. Intended to make declaring all those fiddly #'c[ad]+r'
functions a bit easier