callcc

 

 

Overview

The call_cc function provides a mechanism for terminating a called function prematurely. No matter where the called function is, in terms of recursion depth, call_cc allows the called function to terminate prematurely and return to the spot just after the call_cc invocation.

In order to do this, call_cc creates an artifice called a "current continuation", which is passed to the called function as an argument. The called function must have one and only one argument, which is to be the current continuation created by call_cc

.

The call_cc function passes the current continuation as an argument to function. The current continuation is also a function with one argument which, when invoked, resumes execution from the spot just after the call_cc invocation.

Usage

Use whenever you may need a call back function to a higher recursion level in a program. Multiple call_cc functions can be invoked in the same program. Each continuation will always call back to the call_cc which created it.

 

Syntax


Expression:

(call_cc aFunction)


Arguments Name Type Description
Argument:aFunctionaFunction A function, expecting a current continuation argument, which may terminate prematurely by invoking the current continuation.

Returns:

The value returned by the aFunction argument.



 

Examples

Here are a number of links to Lambda coding examples which contain this instruction in various use cases.

 

Argument Types

Here are the links to the data types of the function arguments.

Lambda Function

Here are also a number of links to functions having arguments with any of these data types.

addMethod argCount argFetch attachLibrarian
balance callcc class compareEQ
compareGE compareGT compareLE compareLT
compareNE compare compile copy
debugBrowsableProcs debug defchild defclass
define(macro) define defmacro defmethod
deforphan defriend defun detachLibrarian
disassemble display evalInSyncLocalContext eval
exportCsv exportSbf exportTab globalBinding
importCsv importSbf importTab inspect
isClass isComplex isEqual isIdentical
isType lambda lisp macroReplace
makeLambda myself new onError
refLibrarian ref saveObject send
setq sizeof super type
writelg writeln

Analytic Information Server (AIS)

AIS Component Systems

  • Smartbase Engine
  • QT C++ Libraries
  • MySQL Relational Database
  • AIS Lisp Libraries
  • Rapid Analytic Demo IDE