[apologies if this is a duplicate, but my mail's been dropping]
There's a lot of good stuff in Apoc2, but I did have at least one
semantic concern. In it, there's this proposal:
: There is likely to be no need for an explicit input operator in Perl 6,
: and I want the angles for something else. I/O handles are a subclass of
: iterators, and I think general iterator variables will serve the purpose
: formerly served by the input operator, particularly since they can
: be made to do the right Thing in context. For instance, to read from
: standard input, it will suffice to say
:
: while ($STDIN) { ... }
I'm wondering what this will do?
$thingy = $STDIN;
This seems to have two possibilities:
1. Make a copy of $STDIN
2. Read a line from $STDIN
To be semantically coherent, it seems that the first one should be the way
it works, like with other variables. That is:
$FILE = open "<$file";
$DUP = $FILE; # dup input stream
$line = <$FILE>; # or $FILE.readline
This gives you some niceties:
$STDERR = $STDOUT; # redirect
Or, it could be that simple assignment instead grabs the iterator:
$line = $FILE; # grabs $FILE.readline, which is next line
$DUP = $FILE.dup; # must call dup() to duplicate filehandle
If it's the latter, then <> is free. However, if it's the former then
we'll still need them. Personally, that latter one scares me a little,
but I'm open-minded.
-Nate