Next: , Previous: , Up: Continuation-Passing Style   [Contents][Index]


9.4.4.3 Building CPS

Unlike Tree-IL, the CPS language is built to be constructed and deconstructed with abstract macros instead of via procedural constructors or accessors, or instead of S-expression matching.

Deconstruction and matching is handled adequately by the match form from (ice-9 match). See Pattern Matching. Construction is handled by a set of mutually recursive builder macros: build-cps-term, build-cps-cont, and build-cps-exp.

In the following interface definitions, consider variables containing cont to be recursively build by build-cps-cont, and likewise for term and exp. Consider any other name to be evaluated as a Scheme expression. Many of these forms recognize unquote in some contexts, to splice in a previously-built value; see the specifications below for full details.

Scheme Syntax: build-cps-term ,val
Scheme Syntax: build-cps-term ($letk (cont ...) term)
Scheme Syntax: build-cps-term ($letrec names syms funs term)
Scheme Syntax: build-cps-term ($continue k src exp)
Scheme Syntax: build-cps-exp ,val
Scheme Syntax: build-cps-exp ($void)
Scheme Syntax: build-cps-exp ($const val)
Scheme Syntax: build-cps-exp ($prim name)
Scheme Syntax: build-cps-exp ($fun src meta free body)
Scheme Syntax: build-cps-exp ($call proc (arg ...))
Scheme Syntax: build-cps-exp ($call proc args)
Scheme Syntax: build-cps-exp ($primcall name (arg ...))
Scheme Syntax: build-cps-exp ($primcall name args)
Scheme Syntax: build-cps-exp ($values (arg ...))
Scheme Syntax: build-cps-exp ($values args)
Scheme Syntax: build-cps-exp ($prompt escape? tag handler)
Scheme Syntax: build-cps-cont ,val
Scheme Syntax: build-cps-cont (k ($kargs (name ...) (sym ...) term))
Scheme Syntax: build-cps-cont (k ($kargs names syms term))
Scheme Syntax: build-cps-cont (k ($kif kt kf))
Scheme Syntax: build-cps-cont (k ($kreceive req rest kargs))
Scheme Syntax: build-cps-cont (k ($kentry self tail-cont ,clauses))
Scheme Syntax: build-cps-cont (k ($kentry self tail-cont (cont ...)))
Scheme Syntax: build-cps-cont (k ($kclause ,arity cont))
Scheme Syntax: build-cps-cont (k ($kclause (req opt rest kw aok?) cont))

Construct a CPS term, expression, or continuation.

There are a few more miscellaneous interfaces as well.

Scheme Procedure: make-arity req opt rest kw allow-other-keywords?

A procedural constructor for $arity objects.

Scheme Syntax: let-gensyms (sym ...) body ...

Bind sym... to fresh names, and evaluate body....

Scheme Syntax: rewrite-cps-term val (pat term) ...
Scheme Syntax: rewrite-cps-exp val (pat exp) ...
Scheme Syntax: rewrite-cps-cont val (pat cont) ...

Match val against the series of patterns pat..., using match. The body of the matching clause should be a template in the syntax of build-cps-term, build-cps-exp, or build-cps-cont, respectively.


Next: , Previous: , Up: Continuation-Passing Style   [Contents][Index]