in reply to Perl 6 coroutines (RFC 31)
Basically, a line likeAre you aware that *exactly* the same problem already exists in Perl? We have several iterators in Perl, for instance, each, readdir, <>, m//g, globbing, and I probably forgot a few. They already act as coroutines. All Damian is proposing is to make that available in Perls user space too.found in a module will test fine, but will suddenly and mysteriously fail if that code is called (even indirectly, by many levels) from another use of the iterator, even if it's on a different collection.while (my $node = $root->next_inorder()) { print $node->{data}; }
You should also realize that someone who uses coroutines knows what he/she is doing. Programmers don't randomly call subs. They call subs because they know what the sub does - and they should also know a sub is a coroutine, and program appropriately.
We also need a "quit" feature. Say I'm iterating over a collection and break out of the loop when I find the element I want. Just last it, and don't look at the rest. Well, next time that code is called, it will still be incomplete...Eh, no we don't. For two reasons. First there is of course return, but more to the point, coroutine like behaviour only happens when yield is used. In the example you present, no yield happens, so it will behave like any other subroutine.
-- Abigail
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Perl 6 coroutines (RFC 31)
by John M. Dlugosz (Monsignor) on Jul 13, 2001 at 18:23 UTC | |
by Abigail (Deacon) on Jul 13, 2001 at 18:38 UTC | |
by John M. Dlugosz (Monsignor) on Jul 13, 2001 at 18:56 UTC |
In Section
Meditations