On Fri, Aug 04, 2000 at 03:13:24PM -0000, Perl6 RFC Librarian wrote:
>   co foo { ... }

>   my $x = co { ... }
> 
>    $y = <|foo>;
> 
>    print |$x "hello, world\n";
> 
> Inside a coroutine, the meanings of "<>" and the default file
> descriptor for print, printf, etc. are overloaded.

Is it just me, or does this look like a tied filehandle with some extra
syntactic sugar and a user-defined subroutine?

    use Coroutine qw(co);

    co foo { }     # creates the filehandle "foo" in the current package,
                   # and ties it to the Couroutine package

    my $x = co { } # ties a filehandle to the Coroutine package and returns it

    # Then everything else is a matter of using the filehandle as normal.

    $y = <foo>;

    print $x "hello, world\n"

The PRINT method can select prior to calling the user-defined subroutine.


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

Reply via email to