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
·········@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.
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.
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