Re: RFC 31 (v1) Co-routines
[email protected] (Chaim Frenkel) 05 Aug 2000 23:12:00 -0400
| Newsgroups | perl.perl6.language.subs |
|---|---|
| Message-ID | <[email protected]> |
Would you please explain the difference (if any) between co-routine generator closure (I vaguely recall, that a co-routine was a set of mutually invoking routines.) Actually, this seems more generic. This might be perfect for an iterator. As for language implications, what would you do with a yield within a map/grep (or future reduce), or is that an implementation detail? <chaim> >>>>> "PRL" == Perl6 RFC Librarian <[email protected]> writes: PRL> =head1 TITLE PRL> Co-routines PRL> =head1 ABSTRACT PRL> This RFC proposes the addition of a new function return command: PRL> C<yield>. Unlike C<return>, C<yield> preserves the execution state of PRL> the subroutine in which it's called, allowing the execution to be PRL> resumed at the following statement, next time the subroutine is called. PRL> It is also proposed that C<yields> may nest, to simplify the PRL> construction of recursive co-routines and iterators. PRL> =head1 BACKGROUND PRL> Normally, when a subroutine returns, its execution terminates PRL> and it final context is completely lost. The next time the subroutine PRL> is invoked, it recommences executing from its first statement. PRL> In a coroutine, a value may be returned in such a way that the PRL> execution of the routine is I<suspended>, along with all its PRL> local context. The next time the routine in invoked, its execution PRL> resumes from the statement after the previous point of return. -- Chaim Frenkel Nonlinear Knowledge, Inc. [email protected] +1-718-236-0183