iVAN wrote:
> As we read in Damian Conway- Perl6-notes, there will be
"...may be..."
(Remember, I'm only the shambling henchman ;-)
> a var-iterator that can be used to see how many times the cycle has
> been "traversed" i.e.
>
> foreach my $el (@ary) {
> .. do something ....
> print $#; <--- print the index (or print $i )
> }
Current thinking is that this functionality may be better provided by bestowing
it on a lexical via a property/trait:
foreach my $el (@ary) {
my $i: index;
...
print $i;
}
This seems preferable since it avoids reintroducing a punctuation variable and
allows nested loop counters to work consistently:
foreach my $el (@ary) {
my $i: index;
for my $el2 (@ary2) {
my $j : index;
@table[$i][$j] = $el * $el2;
}
}
> shall we have :
>
> foreach my $el (@ary) {
> print $# if $#.first();
> .. do something ....
> print $# if $#.last();
> i.e. $#ary
> };
I very much doubt it.
Damian
- LangSpec: Statements and Blocks Bryan C . Warnock
- Redo the next to last goto (was Re: LangSpec: Stat... Bryan C . Warnock
- Re: LangSpec: Statements and Blocks Uri Guttman
- Re: LangSpec: Statements and Blocks Bryan C . Warnock
- Re: LangSpec: Statements and Blocks Damian Conway
- Re: LangSpec: Statements and Blocks Dav�� Helgason
- Re: LangSpec: Statements and Blocks Bryan C . Warnock
- Re: LangSpec: Statements and Blocks Damian Conway
- Re: LangSpec: Statements and Blocks Bryan C . Warnock
- Re: LangSpec: Statements and Blocks Damian Conway
- Re: LangSpec: Statements and Blocks Bryan C . Warnock
- Re: LangSpec: Statements and Blocks Randal L. Schwartz
- Re: LangSpec: Statements and Blocks Damian Conway
- Re: LangSpec: Statements and Blocks Bryan C . Warnock
- Re: LangSpec: Statements and Blocks Bryan C . Warnock
