cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicola Ken Barozzi <>
Subject Re: FYI: Using Java to define Cocoon Flow
Date Fri, 16 May 2003 12:56:35 GMT

Christopher Oliver wrote, On 16/05/2003 11.53:
> Actually, it's very easy if the scripting language doesn't rely on the 
> Java call stack to implement function calls. Instead, it must create its 
> own call-frames and push them on its own stack. The continuation of the 
> current function invocation is simply the stack itself. To instantate a 
> continuation object, you  make a copy of the stack and store it in the 
> continuation object. To implement tail-call elimination, you overwrite 
> the call-frame at the top of the stack with the tail function 
> invocation. To implement continuations, you replace the _entire_ stack 
> with the one stored in the continuation. Other than optimizing the 
> stack-copying, that's it.

Ok, so if I get it right, to support continuations in BSF one has to add 
support in each and every scripting language that needs them, or make 
the bsf handle the stack for them.

Usually, a scripting language author extends the BSFEngineImpl class, 
which implements BSFEngine, and only requires the scripting language 
author to implement the eval() method. However, the following methods 
specified by the BSFEngine interface are the most commonly implemented:

     * initialize() - used to set up the underlying scripting language
     * call() - used to call functions or methods within the scripting
     * eval() - used to evaluate a script
     * exec() - used to execute a script
     * declareBean() - used to create an implicit object
     * undeclareBean() - used to remove an implicit object

So when I run exec() on a script, I loose complete control over it, and 
it's the script that has to stop itself and handle me the continuation 
that I'll have to handle him later:

    * resume(cont)

Am I getting there?

Nicola Ken Barozzi         
             - verba volant, scripta manent -
    (discussions get forgotten, just code remains)

View raw message