From: Philippe Lorin
Subject: Coroutines
Date: 
Message-ID: <44205453$0$7905$636a55ce@news.free.fr>
I need coroutines (actually, a similar construct based on them). I'd 
have thought finding a coroutine package for Lisp would be easy, but 
after a lot of research, the only example I could find is in ELisp [1] 
(despite much talk about coroutines pointing to Lisp or Scheme). I 
should be able to tanslate it, or come up with my own scheme, but I'm 
surprised by the lack of a standard (be it only de facto). Did I miss 
something, or are coroutines just another thing not standardized because 
it's "so easy" to implement yourself?

Anyway, any suggestions for implementation are welcome. What I want to 
do precisely is something like this (this is an ideal example):

(defcorout spit-letters ()
   (print 'a')
   (yield)
   (print 'b'))

(setf running-coroutine (start spit-letters))
(funcall running-coroutine) => a ; no return value
(funcall running-coroutine) => b ; no return value

(defcorout spit-numbers-and-letters (x)
   (print x)
   (yield)
   (incf x)
   (print x)
   (incf x)
   (spit-letters)
   (yield)
   (print x))

(setf running-coroutine (start spit-numbers-and-letters 3))
(funcall running-coroutine) => 3 ; no return value
(funcall running-coroutine) => 4 a ; no return value
(funcall running-coroutine) => b ; no return value
(funcall running-coroutine) => 5 ; no return value



[1] http://www.emacswiki.org/cgi-bin/wiki/coroutine.el

From: Thomas Atkins
Subject: Re: Coroutines
Date: 
Message-ID: <1142969856.714867.138540@u72g2000cwu.googlegroups.com>
It's not exactly a coroutine library but Arnesi (www.cliki.net/arnesi)
contains a cps, you could probably build coroutines on top of that.
From: Thomas Atkins
Subject: Re: Coroutines
Date: 
Message-ID: <1142969907.449780.313920@v46g2000cwv.googlegroups.com>
It's not exactly a coroutine library but Arnesi (www.cliki.net/arnesi)
contains a cps convertor, you could probably build coroutines on top of
that.
From: ········@gmail.com
Subject: Re: Coroutines
Date: 
Message-ID: <1142970461.482565.175120@i39g2000cwa.googlegroups.com>
It's in scheme, but it should be straitforward to translate to lisp

http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-15.html#node_sec_13.4
From: Kalle Olavi Niemitalo
Subject: Re: Coroutines
Date: 
Message-ID: <87y7z3sfgf.fsf@Astalo.kon.iki.fi>
·········@gmail.com" <········@gmail.com> writes:

> It's in scheme, but it should be straitforward to translate to lisp
>
> http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-15.html#node_sec_13.4

That code uses call/cc (aka call-with-current-continuation),
which is neither included in Common Lisp nor trivial to add.
From: Pascal Bourguignon
Subject: Re: Coroutines
Date: 
Message-ID: <87lkv31set.fsf@thalassa.informatimago.com>
Philippe Lorin <············@gmail.com> writes:

> I need coroutines (actually, a similar construct based on them). I'd
> have thought finding a coroutine package for Lisp would be easy, but
> after a lot of research, the only example I could find is in ELisp [1]
> (despite much talk about coroutines pointing to Lisp or Scheme). I
> should be able to tanslate it, or come up with my own scheme, but I'm
> surprised by the lack of a standard (be it only de facto). Did I miss
> something, or are coroutines just another thing not standardized
> because it's "so easy" to implement yourself?

Usually, CL implementations directly jump to threads.
If you aren't using clisp, try threads!


> Anyway, any suggestions for implementation are welcome. What I want to
> do precisely is something like this (this is an ideal example):

Coroutines are easy to implement with continuations.  Perhaps you
should have a look at the continuations implementation in arnesi
(UCW).


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
Litter box not here.
You must have moved it again.
I'll poop in the sink. 
From: Sashank Varma
Subject: Re: Coroutines
Date: 
Message-ID: <1143167639.078535.312920@j33g2000cwa.googlegroups.com>
Philippe Lorin wrote:
> I need coroutines (actually, a similar construct based on them).

My memory is that a nice and simple coroutine package is developed in:

http://www.amazon.com/gp/product/0898596092/103-9237248-9447858?v=glance&n=283155

Sashank