[plt-scheme] (Delimited) continuations versus threads

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Oct 2 07:53:04 EDT 2008

At Wed, 01 Oct 2008 14:40:11 +0200, Jakub Piotr Cłapa wrote:
> 1. If I understand correctly the shift/reset operator could be 
> implemented using threads. (reset starts a child thread and waits for a 
> reply sent by shift; shift sends the reply and binds k to a procedure 
> waiting for further replies). The only difference I can think of is when 
> you try to use the function created by shift multiple times (it will not 
> work with threads). Is it the only difference?

Yes, that sounds right.

> 2. What is the best way to write a nonblocking parser receiving data 
> from a subprocess. Using continuations and feeding new data received on 
> a port or spawning a new thread and using blocking requests?
> 
> I think that a simple thread would be better. 

I agree --- it sounds like a job for threads.

> Are continuations only 
> useful when we want to serialize them to disk or restart the computation 
> many times from the same break (as in HTTP)? 

Mainly the latter, since we don't have serializable continuations in
the PLT Scheme core.

> And what if we had 
> serializable threads?

Then they'd be continuations, because you could deserialize them
multiple times to restart them.


Matthew



Posted on the users mailing list.