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
(macro-aux f)- custom auxiliary data stored with the macro
(macro-aux-set! f x)
(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.
Copies the characters from
dst starting at
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.