Common Lisp Package: CL-CONT

A library that implements continuations by transforming Common Lisp code to continuation passing style.

README:

FUNCTION

Public

CALL/CC (CC)

Implements delimited continuations.

COPY-TRANSFORMATION-CONTEXT (CTX)

Copies transformation context. This is used for cases when the context has to be 'frozen' in time and used at a later transformation stage.

CPSTRANSFORMER (NAME)

Returns a CPS transformer named by a given NAME.

EXPR->CPS (EXPR K-EXPR ENV)

Transforms expression to CPS style.

EXPR-SEQUENCE->CPS (EXPR-LIST K-EXPR ENV)

Converts a list of expressions to be evaluated in order to CPS style.

Private

ACCUM-MC-SEQUENCE->CPS (EXPR-LIST FN K-EXPR ARGS ENV)

Converts a list of expressions to be evaluated in order to CPS style and collects their results (including multiple values).

APPLICATION->CPS (APP-SYM CONS K-EXPR ARGS ENV)

Transforms a function application to CPS style.

APPLY->CPS (CONS K-EXPR ARGS ENV)

Transforms APPLY to CPS style.

ATOM->CPS (ATOM K-EXPR)

Transforms an atom to CPS style.

CONS->CPS (CONS K-EXPR ENV)

Transforms a cons to CPS style.

COPY-HASH-TABLE (HT)

Shallow hashtable copy.

CTX-BLOCK-TAGS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

CTX-GO-TAGS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

CTX-LOCAL-FUNCTIONS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

DECLARE-FUNCTION-NAMES-LOCAL (NAMES)

Declares function names local in a transformation environment.

DUPLICATES-P (SEQUENCE &KEY (KEY #'IDENTITY) (TEST #'EQL))

Returns true if there are duplicate elements in the sequence, false otherwise.

EXTRACT-DECLARATIONS (EXPR-LIST)

Returns a list of declarations extracted from the EXPR-LIST.

FDESIGNATOR-TO-FUNCTION/CC (FDESIGNATOR)

Converts a function designator to a function/cc.

FUNCALL->CPS (CONS K-EXPR ARGS ENV)

Transforms FUNCALL to CPS style.

GROUP-TAGBODY-FORMS (EXPR-LIST)

Groups TAGBODY forms into a list where each item is a list with CAR being the go-tag name (or nil for default first tag), and CDR is a list of expressions for the tag.

LAMBDA-EXPR->CPS (CONS K-EXPR ENV)

Converts a LAMBDA expression to CPS style.

LET*-VARLIST->CPS (VARLIST LET-BODY K-EXPR ENV)

Converts a list of variables from a LET* expression to CPS style.

LET-VARLIST->CONS-PAIRS (VARLIST)

Converts a list of LET vars into name/value cons pairs.

MAKE-FUNCALLABLE (FUNCTION)

Creates an instance of FUNCALLABLE/CC.

NAMED-TB-FORMS>CPS (FORMS K-EXPR ENV)

Takes a list of named TAGBODY forms and converts CAR form to CPS.

REMOVE-DECLARATIONS (EXPR-LIST)

Removes declarations from the EXPR-LIST.

SETQ->CPS (SETQ-PAIRS K-EXPR ENV)

Converts a list of SETQ pairs to CPS style.

TRANSFORM-LOCAL-FUNCTION (FN ENV IN-ENV-P)

Transforms a local (FLET or LABELS) function to CPS style.

UNDECLARE-FUNCTION-NAMES-LOCAL (NAMES)

Undeclares function names local in a transformation environment.

Undocumented

CALL/CC-CONTEXT-P (OBJECT)

COPY-CALL/CC-CONTEXT (INSTANCE)

SETFCTX-BLOCK-TAGS (NEW-VALUE INSTANCE)

SETFCTX-GO-TAGS (NEW-VALUE INSTANCE)

SETFCTX-LOCAL-FUNCTIONS (NEW-VALUE INSTANCE)

MAKE-CALL/CC-CONTEXT (&KEY ((BLOCK-TAGS DUM19) (MAKE-HASH-TABLE)) ((GO-TAGS DUM20) (MAKE-HASH-TABLE)) ((LOCAL-FUNCTIONS DUM21) NIL))

MACRO

Public

DEFCPSTRANSFORMER (NAME LAMBDA-LIST &BODY BODY)

A macro that allows defining special case CPS transformers.

DEFUN/CC (NAME ARGLIST &BODY BODY)

A helper macro to define a function that supports CALL/CC.

LAMBDA/CC (ARGS-LIST &BODY BODY)

A helper macro that wraps LAMBDA definitions with WITH-CALL/CC.

LET/CC (K &BODY BODY)

A shortcut for CALL/CC.

WITH-CALL/CC (&BODY BODY &ENVIRONMENT ENV)

Gives access to CALL/CC by transforming BODY to continuation passing style.

WITHOUT-CALL/CC (&BODY BODY)

A macro that allows writing macros to produce non-CPS code uniformly within and without with-call/cc.

Private

APPLY/CC (FDESIGNATOR K &REST ARGS)

Implements FUNCALL for a CPS converter.

EXPAND-FORM (FORM &ENVIRONMENT ENV)

A helper macro that expands forms by considering local macros.

FUNCALL/CC (FDESIGNATOR K &REST ARGS)

Implements FUNCALL for a CPS converter.

TRANSFORM-FORMS-IN-ENV (FORMS K-EXPR TRANSF-ENV &ENVIRONMENT ENV)

Macroexpands code within a form that sets up a lexical environment and runs a CPS code walker on it.

WITH-LOCAL-FUNCTION-NAMES (NAMES &BODY BODY)

Runs BODY within a transformation environment in which functions named by NAMES are declared as local.

SLOT-ACCESSOR

Private

F/CC-FUNCTION (OBJECT)

A function object that accepts a continuation argument.

SETFF/CC-FUNCTION (NEW-VALUE OBJECT)

A function object that accepts a continuation argument.

VARIABLE

Private

*SPECIAL-FORM-TRANSFORMERS*

A hashtable that maps symbols to functions. Each function acts as a transformer of a special form and must accept three arguments: an s-expression to transform to CPS-style, an an s-expression to continue to, and an environment object.

CLASS

Private

CALL/CC-CONTEXT

A structure that represents a context used during call/cc transformation.

Undocumented

FUNCALLABLE/CC