continuations resources

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

continuations resources

Ramiro Diaz Trepat
I would like to have a better understanding of what continuations are
in general and how is the Seaside implementation.
Why is it that they can not be implemented in Java without changing
the JVM.  Isn't everything implementable on Touring Machines :) ?
Can anybody recomend me a resource to read about it?
Thanks
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: continuations resources

Ramon Leon-5
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf
> Of Ramiro Diaz Trepat
> Sent: Tuesday, October 10, 2006 9:13 AM
> To: The Squeak Enterprise Aubergines Server - general discussion.
> Subject: [Seaside] continuations resources
>
> I would like to have a better understanding of what
> continuations are in general and how is the Seaside implementation.
> Why is it that they can not be implemented in Java without
> Can anybody recomend me a resource to read about it?
> Thanks

Because they were implemented in Squeak, by saving, manipulating, and
restoring the stack.  Java doesn't allow this, so the VM needs changed to
implement continuations.

> changing the JVM.  Isn't everything implementable on Touring
> Machines :) ?

No.. not without writing a Java interpreter that works differently than the
current VM.  It's a mistake to assume Turing equivalence means all languages
have equal expressive power, they don't.  I could mow my lawn with nail
clippers... But I'd rather use a riding lawnmower, but they're both
"capable" of doing the job; that's about all Turing equivalence really
means.

Ramon Leon
http://onsmalltalk.com 

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: continuations resources

Ramiro Diaz Trepat
Thank you for your answers Ramón.
I would still like to have a pointer to some good resources on the
subject to read about.
Thanks again.

r.




On 10/10/06, Ramon Leon <[hidden email]> wrote:

> > -----Original Message-----
> > From: [hidden email]
> > [mailto:[hidden email]] On Behalf
> > Of Ramiro Diaz Trepat
> > Sent: Tuesday, October 10, 2006 9:13 AM
> > To: The Squeak Enterprise Aubergines Server - general discussion.
> > Subject: [Seaside] continuations resources
> >
> > I would like to have a better understanding of what
> > continuations are in general and how is the Seaside implementation.
> > Why is it that they can not be implemented in Java without
> > Can anybody recomend me a resource to read about it?
> > Thanks
>
> Because they were implemented in Squeak, by saving, manipulating, and
> restoring the stack.  Java doesn't allow this, so the VM needs changed to
> implement continuations.
>
> > changing the JVM.  Isn't everything implementable on Touring
> > Machines :) ?
>
> No.. not without writing a Java interpreter that works differently than the
> current VM.  It's a mistake to assume Turing equivalence means all languages
> have equal expressive power, they don't.  I could mow my lawn with nail
> clippers... But I'd rather use a riding lawnmower, but they're both
> "capable" of doing the job; that's about all Turing equivalence really
> means.
>
> Ramon Leon
> http://onsmalltalk.com
>
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: RE: continuations resources

Lukas Renggli
In reply to this post by Ramon Leon-5
> > changing the JVM.  Isn't everything implementable on Touring
> > Machines :) ?
>
> No.. not without writing a Java interpreter that works differently than the
> current VM.

Sure you can do it in Java, you just have to implement your own
runtime environment on top of it. JRuby is doing exactly that and I
believe it supports continuations.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: continuations resources

Ramon Leon-5
In reply to this post by Ramiro Diaz Trepat
>
> Thank you for your answers Ramón.
> I would still like to have a pointer to some good resources
> on the subject to read about.
> Thanks again.
>
> r.

I don't really have any pointers handy, you might try searching this list.  

A simple way to think of continuations, is something like an exception, but
more general.  Exceptions can be implemented via a continuation.  When you
fire an exception, you're essentially saying, here, pass this exception
object to the current continuation, i.e. the nearest exception handler.  

Continuations are more general however, and are capable of being called many
times.  It's like going back in time, somewhere earlier in the code, you
were in a context where you said... Hmm, I want to be able to come back here
and start over, so save this context as the current continuation.  Later,
you find yourself in a situation where you want to bail out and start over
again at that spot, so you invoke the current continuation and do exactly
that, time travel back to that point, and continue from wherever it was,
even if that spot was in the middle of a method somewhere.  The continuation
starts right at the point in the stack where it left off.  Think of it as
calling a no arg method that was created on the fly at any point of your
choosing, even mid execution, at any time in the past.

This is useful in the web context, because you save the continuation, then
render a page to the user, then pack up all the data, put it somewhere, and
restart the continuation right where you left off, as if the render was
instantaneous, allowing the workflow code to be all in one subroutine,
instead of spread out between many pages.

This is my understanding anyway, I could be wrong on some subtle point.
Your best bet, is to read up on Scheme, there's bound to be lots of
documentation on continuations in Scheme, where they're the most popular.

Ramon Leon
http://onsmalltalk.com 

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: RE: continuations resources

Lukas Renggli
> A simple way to think of continuations, is something like an exception, but
> more general.  Exceptions can be implemented via a continuation.  When you
> fire an exception, you're essentially saying, here, pass this exception
> object to the current continuation, i.e. the nearest exception handler.

For me, what did the trick to understand continuations, was the
following piece of code:

Object>>escaperDo: aBlock
   ^ aBlock value: [ :value | ^ value ]

If you try to fully understand what it does, how it can be used and
what its limitations are, then you will also understand continuations
to which the limitations I am talking about don't apply.

So it is more like a quiz ;-)

Lukas


--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: continuations resources

Ramon Leon-5
In reply to this post by Ramon Leon-5
> Continuations are more general however, and are capable of
> being called many times.  It's like going back in time,
> somewhere earlier in the code, you were in a context where
> you said... Hmm, I want to be able to come back here and
> start over, so save this context as the current continuation.
>  Later, you find yourself in a situation where you want to
> bail out and start over again at that spot, so you invoke the
> current continuation and do exactly that, time travel back to
> that point, and continue from wherever it was, even if that
> spot was in the middle of a method somewhere.  The
> continuation starts right at the point in the stack where it
> left off.  Think of it as calling a no arg method that was
> created on the fly at any point of your choosing, even mid
> execution, at any time in the past.

Quite literally, a continuation is a GOTO.

Ramon Leon
http://onsmalltalk.com 

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: continuations resources

Bany, Michel
In reply to this post by Ramiro Diaz Trepat
Did you try wikipedia ?

http://en.wikipedia.org/wiki/Continuation

m.

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf
> Of Ramiro Diaz Trepat
> Sent: Tuesday, October 10, 2006 7:46 PM
> To: The Squeak Enterprise Aubergines Server - general discussion.
> Subject: Re: [Seaside] continuations resources
>
> Thank you for your answers Ramón.
> I would still like to have a pointer to some good resources
> on the subject to read about.
> Thanks again.
>
> r.
>
>
>
>
> On 10/10/06, Ramon Leon <[hidden email]> wrote:
> > > -----Original Message-----
> > > From: [hidden email]
> > > [mailto:[hidden email]] On Behalf Of
> > > Ramiro Diaz Trepat
> > > Sent: Tuesday, October 10, 2006 9:13 AM
> > > To: The Squeak Enterprise Aubergines Server - general discussion.
> > > Subject: [Seaside] continuations resources
> > >
> > > I would like to have a better understanding of what continuations
> > > are in general and how is the Seaside implementation.
> > > Why is it that they can not be implemented in Java without Can
> > > anybody recomend me a resource to read about it?
> > > Thanks
> >
> > Because they were implemented in Squeak, by saving,
> manipulating, and
> > restoring the stack.  Java doesn't allow this, so the VM
> needs changed
> > to implement continuations.
> >
> > > changing the JVM.  Isn't everything implementable on Touring
> > > Machines :) ?
> >
> > No.. not without writing a Java interpreter that works differently
> > than the current VM.  It's a mistake to assume Turing equivalence
> > means all languages have equal expressive power, they
> don't.  I could
> > mow my lawn with nail clippers... But I'd rather use a riding
> > lawnmower, but they're both "capable" of doing the job;
> that's about
> > all Turing equivalence really means.
> >
> > Ramon Leon
> > http://onsmalltalk.com
> >
> > _______________________________________________
> > Seaside mailing list
> > [hidden email]
> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> >
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: continuations resources

William Harford
In reply to this post by Ramiro Diaz Trepat

On Oct 10, 2006, at 1:46 PM, Ramiro Diaz Trepat wrote:

> Thank you for your answers Ramón.
> I would still like to have a pointer to some good resources on the
> subject to read about.
> Thanks again.
>

An article that I liked.

http://www.intertwingly.net/blog/2005/04/13/Continuations-for- 
Curmudgeons

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: continuations resources

Ramiro Diaz Trepat
Thank you very much everyone.
The continuations article on Wikipedia has been enriched.  The last
time I saw it it was much more general, I guess that's what Wikipedia
is about :)
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: continuations resources

Milan Zimmermann-2
In reply to this post by Ramiro Diaz Trepat
Ramiro,

One article that may be interesting:

http://www.defmacro.org/ramblings/fp.html

I browsed through it very quickly a few weeks ago, did not have time to read
it properly but seems good (ignore the first part and go to "Functional
Programming" or all the way to "Continuations"

Milan

On 2006 October 10 12:13, Ramiro Diaz Trepat wrote:

> I would like to have a better understanding of what continuations are
> in general and how is the Seaside implementation.
> Why is it that they can not be implemented in Java without changing
> the JVM.  Isn't everything implementable on Touring Machines :) ?
> Can anybody recomend me a resource to read about it?
> Thanks
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: continuations resources

Bryce Kampjes
In reply to this post by Ramon Leon-5
Ramon Leon writes:
 > Quite literally, a continuation is a GOTO.

It can be a goto with variable bindings that include higher order
functions. But thats straying into the original Scheme continuations,
and some neat papers written in the late '70s.

Bryce
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: continuations resources

tblanchard
In reply to this post by Lukas Renggli
nope - it doesn't and there are no plans to.

http://on-ruby.blogspot.com/2006/10/jruby-interview-part-2.html

On Oct 10, 2006, at 11:23 AM, Lukas Renggli wrote:

>> > changing the JVM.  Isn't everything implementable on Touring
>> > Machines :) ?
>>
>> No.. not without writing a Java interpreter that works differently  
>> than the
>> current VM.
>
> Sure you can do it in Java, you just have to implement your own
> runtime environment on top of it. JRuby is doing exactly that and I
> believe it supports continuations.
>
> Lukas
>
> --
> Lukas Renggli
> http://www.lukas-renggli.ch
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: continuations resources

Jason Johnson-3
In reply to this post by Ramiro Diaz Trepat
Ramiro Diaz Trepat wrote:
> Isn't everything implementable on Touring Machines :) ?

Yes.  But some times you use the "Touring Machine" to impliment a
language, and then program in that language.  That is what you would
have to do in Java, C++, C, assemble language and many (most) others.  
Smalltalk and Lisp make it quite a bit easier to do such things.
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: continuations resources

Jason Johnson-3
In reply to this post by Ramon Leon-5
Ramon Leon wrote:
> Quite literally, a continuation is a GOTO.

Kind of, but unlike virtually every language that uses GOTO, in a
continuation you define the goto "tag" on the fly and then return to it
later.

How I like to think of a continuation is how operating systems (sensible
ones anyway) handle memory paging/swapping.  A process is running along
happily and then it tries to access a part of memory that has already
been swapped to disk.  This generates an exeption into the OS who
basically puts this process to sleep.  The OS then does what it needs to
to ensure the call will work (i.e. swaps something else that hasn't been
used recently onto disk, pulls the memory off disk and stores it in this
newly reclaimed space, etc.) and then wakes the process back up.  From
the process' point of view he just tried to access a part of memory and
it worked.  He has no idea, and no way (well no easy way) to know that
he was put in suspended animation until the illusion of the world he
expects could be properly built for him.
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside