develooper Front page | perl.perl6.language | Postings from December 2004

while idiom [Was: Arglist I/O [Was: Angle quotes and pointy brackets]]

From:
Larry Wall
Date:
December 6, 2004 09:57
Subject:
while idiom [Was: Arglist I/O [Was: Angle quotes and pointy brackets]]
Message ID:
20041206175657.GB3413@wall.org
On Mon, Dec 06, 2004 at 10:38:10AM -0500, Austin Hastings wrote:
: ===== Idiom:
: 
: The other concern is idiom. Using C<for> suggests "start at the 
: beginning, continue to the end". OTOH, using C<while> is a little 
: "weaker" -- "keep doing this until it's time to stop". Obviously they'll 
: usually be used in the same way:
: 
: for =<> {...}   vs.     while (<>) {...}
: 
: This seems a subtle concern, and maybe it's just my latent fear of 
: change making me uncomfortable, but I actually *think* in english -- not 
: that it does much good -- and this isn't how I think.
: 
: Can we ditch C<for> in the examples in favor of C<while>, for a while? :)

Okay.  Have an example:

    while =$IN -> $line {...}

I think that works.  I'm back to thinking unary = in scalar context iterates
like p5's <>, and you should use extraordinary means to get extraordinary
results:

    while file $IN -> $blob {...}
    while slurp $IN -> $bigblob {...}

Larry



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