my $fh = open(@ARGS[0]);
my @lines = =$fh;
$fh.close();
for @lines { print"$_" }
running:
pugs t.p6 t.p6
produces no output. Move $fh.close() to after the for
loop and all is well. Is this a bug?
/-\
Find local movie times and trailers on Yahoo! Movies.
http://au.movies.yahoo.com
Hmm. It's probably a design bug. I'm wondering if we have to specify
that ordinary assignment not only copies logically but, in fact, always
does ** flattening (immediate flattening) like Perl 5, and you *must*
use := binding to get lazy flattening. That is probably the course
of sanity. Since assignment is the primary means of violating FP's
no-side-effect idea, it makes sense that assignment is also what tries
its hardest to work around the issue when the user requests a side
effect like assignment. For example,
@foo = 1...;
would be an outright error, detectable at compile time in this case, while
@foo := 1...;
is perfectly fine. But my coffee isn't ready yet this morning,
so I reserve the right to be wronger than usual.
[Followups directed by default to p6l.]
Larry