Abstract Syntax Tree. Interface to the types used by the compiler, and other core types less commonly needed in user code, plus related utilities.
Expands and analyzes the expression
x and returns the
Runs an optimization pass on
ast and returns the
resulting simplified expression.
Performs a full syntax expansion of the form
returns the resulting s-expression.
ast to a s-expression, renaming variables if
All objects have an associated type, and types may have parent
types. When using
define-record-type, the name is bound to a first class
The following core types are also available by name, and may be
used in the
($ ...) syntax.
<object>- the parent of all types
<number>- abstract numeric type
<bignum>- arbitrary precision exact integers
<flonum>- inexact real numbers
<integer>- abstract integer type
<string>- strings of characters
<byte-vector>- uniform vector of octets
cdr, the basis for lists
<opcode>- a primitive opcode or C function
<procedure>- a closure
<bytecode>- the compiled code for a closure
<env>- an environment structure
<macro>- a macro object, usually not first-class
<lam>- a lambda AST type
<cnd>- an conditional AST type (i.e.
<ref>- a reference AST type
<set>- a mutation AST type (i.e.
<seq>- a sequence AST type
<lit>- a literal AST type
<sc>- a syntactic closure
<context>- a context object (including threads)
<exception>- an exception object
The following extended type predicates may also be used to test individual objects for their type:
Returns the type of any object
Returns the name of type
Returns the immediate parent of type
#f for a type with no parent.
Returns the class precedence list of type
type as a
#f for a type with no parent.
Returns the slot list of type
This section describes additional accessors on AST and other core types.
(procedure-code f)- the compiled bytecode object
(procedure-vars f)- the variables closed over by
(procedure-name f)- the name of
fif known, else
(macro-procedure f)- the macro procedure
(macro-env f)- the environment the macro was defined in
(macro-source f)- the source location the macro was defined in
(bytecode-name bc)- the macro procedure
(bytecode-literals bc)- literals the bytecode references
(bytecode-source bc)- the source location the procedure was defined in
Return the environment, free variables, and expression
Return the kind, message, and irritants
(lambda-name lam)- the name of the lambda, if known
(lambda-name-set! lam x)
(lambda-params lam)- the lambda parameter list
(lambda-params-set! lam x)
(lambda-body lam)- the body of the lambda
(lambda-body-set! lam x)
(lambda-defs lam)- internal definitions of the lambda
(lambda-defs-set! lam x)
(lambda-locals lam)- local variables as a list of identifiers
(lambda-locals-set! lam x)
(lambda-flags lam)- various flags describing the lambda
(lambda-flags-set! lam x)
(lambda-free-vars lam)- free variables the lambda will need to close over
(lambda-free-vars-set! lam x)
(lambda-set-vars lam)- variables the lambda mutates
(lambda-set-vars-set! lam x)
(lambda-return-type lam)- the return type of the lambda
(lambda-return-type-set! lam x)
(lambda-param-types lam)- the types of the input parameters
(lambda-param-types-set! lam x)
(lambda-source lam)- the source code of the lambda
(lambda-source-set! lam x)
(cnd-test cnd)- the test for the conditional
(cnd-test-set! cnd x)
(cnd-pass cnd)- the success branch
(cnd-pass-set! cnd x)
(cnd-fail cnd)- the failure branch
(cnd-fail-set! cnd x)
(seq-ls seq)- the list of sequence expressions
(seq-ls-set! seq x)
(ref-name ref)- the name of the referenced variable
(ref-name-set! ref x)
(ref-cell ref)- the environment cell the reference resolves to
(ref-cell-set! ref x)
(set-var set)- a reference to the mutated variable
(set-var-set! set x)
(set-value set)- the value to set the variable to
(set-value-set! set x)
(lit-value lit)- the literal value
(lit-value-set! lit x)
(pair-source-set! x source)
Set or return the source code info associated with a pair x.
Source info is represented as another pair whose
the source file name and whose
cdr is the line number.
Force a garbage collection.
Returns the heap space directly used by
counting any elements of
Returns the interpretation of the integer
an immediate object, useful for debugging.
Returns the first string cursor of
#f if it's not found.
setenv but does nothing and returns
value is a function definition. Used to
circumvent the vulnerability of the shellshock bug.
expr atomically, disabling yields. Ideally should only be
used for brief, deterministic expressions. If used incorrectly (e.g.
running an infinite loop) can render the system unusable.
Never expose to a sandbox.