JavaScript with Continuations and its use in Apache Cocoon
started 8/2/2003; 5:51:55 PM - last post 8/6/2003; 6:28:31 PM
|
|
Robert Sayre - JavaScript with Continuations and its use in Apache Cocoon
8/2/2003; 5:51:55 PM (reads: 1638, responses: 8)
|
|
|
Dan Shappir - Re: JavaScript with Continuations and its use in Apache Cocoon
8/3/2003; 1:10:56 AM (reads: 1652, responses: 0)
|
|
This is really cool and it will take me a while to think through the implications.
Just having tail-call elimination is great for BeyondJS because BeyondJS's flow control is based on function calls (it is, after all, a functional library ;-)
With regard to the continuations extension a few quick observations:
- Standard JavaScript implements an
arguments object that aside from containing a collection of all a function's argument values, also provides caller and callee properties. These are references to the calling function and the function being called respectively. It's interesting continuations where implemented using new Continuation rather than a continuation property on the arguments object. This is nitpicking of course.
- Interesting that you apparently don't need a
try statement for catch(break) and catch(continue) . Indeed, the use of catch may be less than ideal given its existing role for exceptions.
- It's a shame IMO that you still can't access a scope, as preserved by the continuation object as an object, e.g.
function getContinuation() {
return new Continuation();
}
var x = 1;
print(x); // output 1
var c = getContinuation();
c.scope.x = 2; // my made up syntax
print(x); // output 2
You would be able to travel up the scope using a parent property on the scope, or something like that. You actually don't need continuations for this, it scope could simply be added a property on callee .
IMO getContinuation() functionality seems to be something they should have provided out-of-the-box.
And BTW BeyondJS does work on a previous version of Rhino. I will have to download this one to test it.
|
|
Ehud Lamm - Re: JavaScript with Continuations and its use in Apache Cocoon
8/3/2003; 1:27:29 AM (reads: 1649, responses: 0)
|
|
This version of Rhino also contains experimental support for serializing Continuations. Thus you may save the state of an executing script and restore it later.
Who needs the PLT webserver, right?
|
|
nraynaud - Re: JavaScript with Continuations and its use in Apache Cocoon
8/3/2003; 6:49:33 PM (reads: 1410, responses: 0)
|
|
I don't know anything about this interpreter, but reading that :
1) continuations are a first-class citizens
2) continuations are serializable
It would be a shame not creating a toy-demo of migratable agents in this interpreter :-)
|
|
Patrick Logan - Re: JavaScript with Continuations and its use in Apache Cocoon
8/3/2003; 8:58:24 PM (reads: 1383, responses: 0)
|
|
It would be a shame not creating a toy-demo of migratable agents in this interpreter
This is a great idea. There's a ton of interesting patterns that can be implemented with migratable continuations.
See Kelsey, et al.'s work with this on Kali Scheme...
Some of the applications and implementation techniques we have looked at using Kali Scheme include:
User-level load balancing and migration.
Incremental distributed linking of code objects.
Parameterized client-server applications.
Long-lived parallel computations.
Distributed data mining.
Executable content in messages over wide-area networks (e.g. the World-Wide Web)
|
|
nraynaud - Re: JavaScript with Continuations and its use in Apache Cocoon
8/3/2003; 9:34:49 PM (reads: 1394, responses: 0)
|
|
This is a great idea
Well, not exactly, it come from a problem we had during a last year course, the prof. wanted us to make a toy migratable agent (to find the best price for an article in a group of supermarket) in java , wich lack facilities to make one (without putting a toy virtual machine over the java virtual machine off-course).
thanks for the links, I never thought in this area before.
edit : reading the wiki, more precisely WhatIsFlow , I just think that there is no mean to say that the "one" that stored the continuation (apache instance, physical processor, database connection used, instance of the JS virtual machine, etc.), is the "one" that will deserialize it and "continue" it, yelding an intrinsic migration. This is very interesting.
|
|
Vadim Nasardinov - Re: JavaScript with Continuations and its use in Apache Cocoon
8/4/2003; 6:54:28 AM (reads: 1275, responses: 0)
|
|
The ATCT thingy from Velare sounds very much like PicoThreads: Lightweight Threads in Java by Andrew Begel, Josh MacDonald,
and Michael Shilman. What makes the PicoThreads paper more
interesting than ATCT is that the Berkeley guys actually talk how they go about implementing continuations and CPS conversion in Java,
whereas the Velare folks have chosen to keep the details to themselves.
|
|
Ben Menasha - Re: JavaScript with Continuations and its use in Apache Cocoon
8/6/2003; 6:28:31 PM (reads: 1047, responses: 0)
|
|
|
|
|