Structs and function calls¶
cexpr-cline-struct¶
Call with main-tag-name projections
Given a main tag name and an ordered assoc list from mutually unique projection names to compiled expressions, returns another compiled expression with the union of their free variables. It represents an expression that returns a cline of the specified constructor which applies a different cline to each projection in order, short-circuiting if any is nonequal.
cline-struct¶
Macro. Example:
(cline-struct cons (cline-struct nil) (cline-struct nil))
Todo
Document this.
cexpr-merge-struct¶
Call with main-tag-name projections
Given a main tag name and an ordered assoc list from mutually unique projection names to compiled expressions, returns another compiled expression with the union of their free variables. It represents an expression that returns a merge of the specified constructor which applies a different merge to each projection.
merge-struct¶
Macro. Example:
(merge-struct cons (merge-struct nil) (merge-struct nil))
Todo
Document this.
cexpr-fuse-struct¶
Call with main-tag-name projections
Given a main tag name and an ordered assoc list from mutually unique projection names to compiled expressions, returns another compiled expression with the union of their free variables. It represents an expression that returns a fuse of the specified constructor which applies a different fuse to each projection.
fuse-struct¶
Macro. Example:
(fuse-struct cons (fuse-struct nil) (fuse-struct nil))
Todo
Document this.
cexpr-construct¶
Call with main-tag-name projections
Given a main tag name and an ordered assoc list from mutually unique projection names to compiled expressions, returns another compiled expression with the union of their free variables. It represents a construction of the specified constructor.
cexpr-case¶
Call with subject main-tag-name bindings then else
Given a main tag name, a compiled expression subject
, a table from projection names to mutually unique local variable names, a compiled expression then
, and a compiled expression else
, returns another compiled expression with all the free variables of subject
and else
and all but the given local variable names out of the free variables of then
. It represents a destructuring branch that conditionally evaluates then
or else
depending on whether subject
has the specified constructor.
case¶
Macro. Example:
(case rev-past cons elem rev-past
(rev-append rev-past /cons elem rest)
rest)
Todo
Document this.
cexpr-call¶
Call with func arg
Given two compiled expressions, returns another compiled expression with the union of their free variables. It represents a function call invoking the first expression’s result with the second expression’s result.
c¶
Macro. Example: (c combiner a b)
Todo
Document this.
constructor-tag¶
Construct with main-tag projections
A value that refers to the tag of a struct value with the indicated main tag name and the projection names appearing as keys in the indicated table of (nil).
Function behaviors are associated with this aspect of a struct, so this struct is the kind of value procure-function-definer expects. A defn call builds and uses this value internally.
function-implementation-from-cexpr¶
Call with cexpr
Given a compiled expression, returns a compiled function implementation. Whenever this implementation is used, the expression will be evaluated, and its result will be invoked with the value being called and the argument it’s being called with. The expression must have no free variables.
constructor-glossary¶
Construct with main-tag source-to-rep
Indicates a constructor’s main tag name and an assoc list mapping mutually unique source-level names to the constructor’s mutually unique projection names. This is a data structure def-struct puts in the definition namespace using procure-constructor-glossary-getdef so macros like case can determine details of a constructor based on a source-level name. The names used in the representation of the constructor may be different from the names used in the source code.
procure-constructor-glossary-getdef¶
Call with ns source-main-tag-name
From a standard but obscure location known as $$constructor-glossary
in the given namespace, obtains a getdef that is used to associate the given source-level main tag name with data about a constructor. The built-in macros that deal with constructors (e.g. case) will expect the value to be a (constructor-glossary …) struct containing a main tag name and an assoc list mapping mutually unique source-level projection names to the mutually unique projection names that are actually used in the struct’s representation.
copy-function-implementations¶
Call with from-ns to-ns
Monadically, blocks until the first given namespace has a function implementation namespace defined (at a standard but obscure location known as $$function-implementations
) and defines it in the second given namespace.
committing-to-define-function-implementations¶
Call with ns effects
Todo
Implement and use this.
Monadically, executes the given effects in a later tick and commits to defining a function implementation namespace on the given namespace (using copy-function-implementations) in that tick or later.
This is only useful to suppress error messages about the definition not existing if there’s an error in this logical thread.
procure-function-definer¶
Call with ns constructor-tag
Blocks until the given namespace has a function implementation namespace defined (at a standard but obscure location known as $$function-implementations
) and obtains a definer that establishes an association from a given constructor-tag to a defined compiled function implementation.
def-struct¶
Macro. Example: (def-struct cons car cdr)
Todo
Document this.
defn¶
Macro. Example:
(defn rev-append rev-past rest
(case rev-past cons elem rev-past
(rev-append rev-past /cons elem rest)
rest))
Todo
Document this.
caselet¶
Macro. Example:
(caselet combiner-result (c combiner a b) yep -
combiner-result
/do-something-else/nil)
Todo
Document this.
cast¶
Macro. Example:
(cast rev-past cons elem rev-past
rest
/rev-append rev-past /cons elem rest)
Todo
Document this.
fn¶
Macro. Example: (fn a b /int-minus b a)
Todo
Document this.