Name

JooseX.CPS.Continuation - A continuation class

SYNOPSIS

    TRY = function () {
        var continuation = new JooseX.CPS.Continuation()

        return continuation.TRY.apply(continuation, arguments)
    }

DESCRIPTION

JooseX.CPS.Continuation implements a continuation - an underlaying basis for JooseX.CPS trait.

ISA

None.

DOES

None.

TRAITS

None.

ATTRIBUTES

parent

JooseX.CPS.Continuation parent

A parent for this continuation. Can be asked for default scope or for the nextFunc

previous

JooseX.CPS.Continuation previous

A previous continuation for this continuation. Can be asked for default scope or for the nextFunc

statements

Array statements

An array of statements. Each statement is an object like :

        {
            func    : ... , // function to execute
            scope   : ... , // scope into which execute the function
            args    : ...   // arguments for function 
        }

type

String type

The type of this continuation. Can be 'Sequential' or 'Parallel's

entered

Boolean entered

The sign whether this continuation was already entered - i.e. activated.

leaved

Boolean leaved

The sign whether this continuation was already leaved - i.e. the CONTINUE or THROW method were called.

defaultScope

Object defaultScope

The default scope which will be supplied to the statements if not provided explicitly. Once passed to TRY, propagates to the further statements.

nextFunc

Function nextFunc

If present, this function will be called, when leaving this continuation. Will be called in the global scope, with the arguments from the method, initated the leave.

catchFunc/finallyFunc

Function catchFunc/finallyFunc

The functions for CATCH/FINALLY statements accordingly.

catchScope/finallyScope

Object catchScope/finallyScope

The scopes for CATCH/FINALLY statements accordingly.

METHODS

TRY

JooseX.CPS.Continuation TRY(Function func, Object scope?, Array args?)

Add a statement to the current continuation. If continuation already contains CATCH or FINALLY statements - then delegate to NEXT and return a next continuation instance. otherwise return current continuation.

THEN

JooseX.CPS.Continuation THEN(Function func, Object scope?, Array args?)

Alias for TRY with a single exception. If the type of the continuation is Parallel then delegate to NEXT and return a next continuation instance.

Has a lower-case synonym : 'then'

CATCH

JooseX.CPS.Continuation CATCH(Function func, Object scope?)

Add a CATCH statement to the current continuation.

Has a lower-case synonym : 'except'

FINALLY

JooseX.CPS.Continuation FINALLY(Function func, Object scope?)

Add a FINALLY statement to the current continuation.

Has a lower-case synonym : 'ensure'

NEXT

JooseX.CPS.Continuation NEXT(Function func, Object scope?, Array args?)

Derive a sibling continuation, chaining it after itself. Return newly created continuation.

Has a lower-case synonym : 'next'

AND

JooseX.CPS.Continuation AND(Function func, Object scope?, Array args?)

Alias for TRY that also switch a type of the continuation to Parallel.

Has a lower-case synonym : 'and'

NOW

JooseX.CPS.Continuation NOW()

Activates current continuation graph by looking the 1st not yet entered continuation. After finding it, delegate to its entry method with the passed arguments.

Has a lower-case synonym : 'now'

getCONTINUE

Function getCONTINUE()

Return a function, binded to the CONTINUE method of itself.

getRETURN

Function getRETURN()

Return a function, binded to the RETURN method of itself.

getTHROW

Function getTHROW()

Return a function, binded to the THROW method of itself.

GETTING HELP

This extension is supported via github issues tracker: http://github.com/SamuraiJack/JooseX-CPS/issues

For general Joose questions you can also visit the #joose on irc.freenode.org, or the forum at http://joose.it/forum

SEE ALSO

Main documentation page

General documentation for Joose: http://joose.github.com/Joose/

AUTHORS

Nickolay Platonov nplatonov@cpan.org

COPYRIGHT AND LICENSE

Copyright (c) 2009, Nickolay Platonov

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.