beowulf.bootstrap
Lisp as defined in Chapter 1 (pages 1-14) of the Lisp 1.5 Programmer's Manual
; that is to say, a very simple Lisp language, which should, I believe, be sufficient in conjunction with the functions provided by beowulf.host
, be sufficient to bootstrap the full Lisp 1.5 interpreter..
The convention is adopted that functions in this file with names in ALLUPPERCASE are Lisp 1.5 functions (although written in Clojure) and that therefore all arguments must be numbers, symbols or beowulf.cons_cell.ConsCell
objects.
APPLY
(APPLY function args environment depth)
Apply this function
to these arguments
in this environment
and return the result.
For bootstrapping, at least, a version of APPLY written in Clojure. All args are assumed to be symbols or beowulf.cons-cell/ConsCell
objects. See page 13 of the Lisp 1.5 Programmers Manual.
EVAL
(EVAL expr)
(EVAL expr env depth)
Evaluate this expr
and return the result. If environment
is not passed, it defaults to the current value of the global object list. The depth
argument is part of the tracing system and should not be set by user code.
All args are assumed to be numbers, symbols or beowulf.cons-cell/ConsCell
objects.
INTEROP
(INTEROP fn-symbol args)
Clojure (or other host environment) interoperation API. fn-symbol
is expected to be either
- a symbol bound in the host environment to a function; or
- a sequence (list) of symbols forming a qualified path name bound to a function.
Lower case characters cannot normally be represented in Lisp 1.5, so both the upper case and lower case variants of fn-symbol
will be tried. If the function you’re looking for has a mixed case name, that is not currently accessible.
args
is expected to be a Lisp 1.5 list of arguments to be passed to that function. Return value must be something acceptable to Lisp 1.5, so either a symbol, a number, or a Lisp 1.5 list.
If fn-symbol
is not found (even when cast to lower case), or is not a function, or the value returned cannot be represented in Lisp 1.5, an exception is thrown with :cause
bound to :interop
and :detail
set to a value representing the actual problem.
interop-interpret-q-name
(interop-interpret-q-name l)
For interoperation with Clojure, it will often be necessary to pass qualified names that are not representable in Lisp 1.5. This function takes a sequence in the form (PART PART PART... NAME)
and returns a symbol in the form PART.PART.PART/NAME
. This symbol will then be tried in both that form and lower-cased. Names with hyphens or underscores cannot be represented with this scheme.
to-beowulf
(to-beowulf o)
Return a beowulf-native representation of the Clojure object o
. Numbers and symbols are unaffected. Collections have to be converted; strings must be converted to symbols.
to-clojure
(to-clojure l)
If l is a beowulf.cons_cell.ConsCell
, return a Clojure list having the same members in the same order.
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