Hey all,

Here's a simple hand coded example that
(correctly, AFAIK) prints "ab" in vanilla
parrot, but goes off in an infinite
loop with the --python flag.

Why does --python mode modify the
behaviour of coroutines?

I thought perhaps they were used for
generators or "for...in" iteration, but
that doesn't seem to be the case. I
can't find any python stuff that uses
them at all. Is it dead code, or am I
missing something?

Sam sent me a patch for pirate that leans
on the work done in --python... I just got
my generator code working with vanilla
parrot, but it doesn't work at all with
the --python flag.

I know the --python stuff is temporary but
it would be nice to be able to integrate
the pie-thon code with pirate.

- Michal
http://withoutane.com/


## gen.pir #############################
#
# parrot gen.pir : prints "ab"
# parrot --python gen.pir : hangs
#

.sub __main__
    .local object gen
    .local object res

    gen = global "_gen_g"

loop:
    res = gen()
    print res
    goto loop

    end
.end

.sub _gen_g prototyped
    .local object res
    res = new PerlString

    res = "a"
    .pcc_begin_yield
    .return res
    .pcc_end_yield

    res = "b"
    .pcc_begin_yield
    .return res
    .pcc_end_yield

    print "\n"
    end
.end

Reply via email to