Front page | perl.perl6.language |
Postings from July 2006
Re: Containers
Thread Previous
|
Thread Next
From:
Aaron Sherman
Date:
July 11, 2006 09:15
Subject:
Re: Containers
Message ID:
1152634421.28796.349.camel@pps
On Tue, 2006-07-11 at 10:06 -0400, Aaron Sherman wrote:
> For example:
>
> our List multi Container::each(Container *@containers)
In thinking about each, I've come across an interesting need. I wrote
this example:
for each(=<>; 1..*) -> ($line, $lineno) {
say "$lineno: $line";
}
Which is obviously an infinite loop. You could re-write that:
for each(=<>; 1..*) -> ($line, $lineno) {
$line err last;
say "$lineno: $line";
}
But would it be reasonable to also provide a named-only parameter to
each for that purpose?
our List multi Container::each(Bool :$stop, Container *@containers)
So that:
for each(:stop, =<>; 1..*) -> ($line, $lineno) {
say "$lineno: $line";
}
would only iterate until one of the containers was exhausted (in this
case, the filehandle).
Should this be added? Should zip have the same modifier?
--
Aaron Sherman <ajs@ajs.com>
Do you find yourself thinking Unicode has too many crosses? ✙✚✛✜✝✞✟✠☦☨☩†
Thread Previous
|
Thread Next