On 18 Aug 2000, Ariel Scolnicov wrote:
> Actually, this suggests that C<values @array> should return
> C<(@array)> (a copy of the values), and C<keys @array> the list
> C<(0..$#array)>. But those aren't very useful.
I like the proposed syntax! I also think that C<keys @array> would be
useful, I often use arrays as integer-based lookups (like for database
results, primary keys and field names). To loop through a list like that,
where the array doesn't start at 0, nor has a consistent increment, I
practically have to kloodge the darn thing, doing:
$i = 0;
foreach(@array) {
$i++;
...
}
or:
for($i = 0; $i <= $#array; $i++) {
next unless $array[$i];
...
}
this:
while(($index, $value) = each(@array)) {
...
}
Seems much more elegant, although maybe we should stick to for* commands
for arrays.
--
Mike Pastore
[EMAIL PROTECTED]
- RFC 120 (v2) Implicit counter in for statements, pos... Perl6 RFC Librarian
- Re: RFC 120 (v2) Implicit counter in for statem... Christopher J. Madsen
- Re: RFC 120 (v2) Implicit counter in for st... Glenn Linderman
- Re: RFC 120 (v2) Implicit counter in for st... David L. Nicol
- Re: RFC 120 (v2) Implicit counter in fo... Christopher J. Madsen
- Re: RFC 120 (v2) Implicit counter i... Jonathan Scott Duff
- Re: RFC 120 (v2) Implicit coun... Christopher J. Madsen
- Re: RFC 120 (v2) Implicit ... Jonathan Scott Duff
- Re: RFC 120 (v2) Impli... Christopher J. Madsen
- Re: RFC 120 (v2) Implicit ... Ariel Scolnicov
- Re: RFC 120 (v2) Impli... Mike Pastore
- Re: RFC 120 (v2) Impli... David L. Nicol
- Re: RFC 120 (v2) Impli... Johan Vromans
- Re: RFC 120 (v2) Impli... Buddha Buck
- Re: RFC 120 (v2) Implicit counter in for st... Ken Fox
- Re: RFC 120 (v2) Implicit counter in fo... Graham Barr
- Re: RFC 120 (v2) Implicit counter i... Peter Scott
- Re: RFC 120 (v2) Implicit counter in for statem... Nathan Torkington
- Re: RFC 120 (v2) Implicit counter in for statem... Steve Simmons
- Re: RFC 120 (v2) Implicit counter in for st... John McNamara
- Re: RFC 120 (v2) Implicit counter in fo... Jonathan Scott Duff
