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