develooper Front page | perl.perl6.language | Postings from March 2005

Re: [Pugs] Closing a file handle surprised the heck out of me

Thread Next
From:
Larry Wall
Date:
March 14, 2005 08:06
Subject:
Re: [Pugs] Closing a file handle surprised the heck out of me
Message ID:
20050314160608.GA11903@wall.org
On Mon, Mar 14, 2005 at 10:58:00PM +1100, Andrew Savige wrote:
: Given this Pugs program, t.p6:
: 
: 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?

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

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About