Klaas-Jan Stol <[EMAIL PROTECTED]> wrote:
> Hello,

> "Are you sure Parrot support "true" coroutines? Does it integrate
> coroutines and closures correctly? (For instance, a single closure may
> refer to variables in several different coroutines.)"

Well, I don't know how "true" coroutines are defined, but Parrot, as
it's CPS based, has no problems with coroutines and there are no
restrictions to coroutines, AFAIK.

How coroutines finally really behave WRT argument passing isn't really
layed out. There is a good article in Dan's blog IIRC.

> co = coroutine.create(function ()
>        for i=1,10 do
>          print("co", i)
>          coroutine.yield()
>        end
>      end)

In Parrot's enough to include a .yield() ...

,--[ simplest usage ]-
| $ cat coro.imc
| .sub main @MAIN
|   $I0 = coro()
|   print $I0
|   $I0 = coro()
|   print $I0
| .end
| .sub coro
|   .yield(4)
|   .yield(2)
| .end
|
| $ ./parrot coro.imc
| 42
`---------------------

to get a static coroutine. Above Lua snippet would use the C<newsub>
opcode to create a Coroutine function object. Such objects act as
closures too (modulo untested, unimplemented features ;)

> thanks,
> Klaas-Jan

leo

Reply via email to