beowulf.interop
TODO: write docs
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.
interpret-qualified-name
(interpret-qualified-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.
listify-qualified-name
(listify-qualified-name subr)
We need to be able to print something we can link to the particular Clojure function subr
in a form in which Lisp 1.5 is able to read it back in and relink it.
This assumes subr
is either 1. a string in the format #'beowulf.io/SYSIN
or beowulf.io/SYSIN
; or 2. something which, when coerced to a string with str
, will have such a format.
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.