I don't see the need for a new keyword. An attribute should be fine

        sub foo : coroutine { }

Would do quite well. It would fit with the :method attribute, and
a possible :lvalue attribute.

Anyway, isn't what you are proposing more of a generator/sink rather
than a coroutine? I understood a coroutine to be a set of mutual
calling functions/procedures.

I also see this as more appropriate to the -language group.

Hmm, would a 
        return :here EXPR
handle the resumption issues?

<chaim>

PRL> =head1 DESCRIPTION

PRL> This proposal introduces a new keyword to perl, "co", as a complement
PRL> to "sub".  A subroutine is defined thusly:

PRL>   co foo { ... }

PRL> Coroutines can also be closures:

PRL>   my $x = co { ... }

PRL> Unlike coroutines as defined by Knuth, and implemented in laguages
PRL> such as Simula or Python, perl does not have an
PRL> explicit "resume" call for invoking coroutines.  Instead, perl uses a
PRL> mechanism that perl programmers are already familiar with: pipes.
PRL> Note that these are intra-process pipes, and would be implemented
PRL> differently than kernel pipes.

PRL> Coroutines are identified by a prefixed vertical bar.  To invoke a
PRL> coroutine, you write data to or read data from it.

PRL>    $y = <|foo>;

PRL>    print |$x "hello, world\n";

-- 
Chaim Frenkel                                        Nonlinear Knowledge, Inc.
[EMAIL PROTECTED]                                               +1-718-236-0183

Reply via email to