At 03:13 PM 8/4/00 +0000, Perl6 RFC Librarian wrote:
>Coroutines for Perl
[I think this belongs on the language list, FWIW, Cc'd there]
I like this, but I'd like to see this, inter-thread queues, and events all
use the same communication method. Overload filehandles to pass events
around instead, so:
my $thing = <$handle>;
could read a record from a file, or get an event from the event queue, or
receive some data from another thread. (With perhaps <$foo> in an lvalue
context being the same as sending a message down the filehandle to
whatever's on the other end)
Also, I'd rather use sub attributes rather than a new keyword. Something like:
sub foo : coroutine($fh) {}
to declare the sub as a coroutine that talks on the filehandle $fh. (As far
as the sub is concerned) Invoking the coroutine could use another keyword,
perhaps invoke, that returns the filehandle the coroutine talks on. So:
$fh = invoke foo("1", "2", "3")
would fire up the coroutine foo, pass it 1, 2, and 3 in @_, and return to
the caller the filehandle that foo's synchronizing on. Expanding it to have
separate in and out filehandles or something also wouldn't be unreasonable.
This would necessitate the expansion of select to check for pending
events/coroutine writes/data, but that's likely to happen anyway, so...
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk