Jonathan Scott Duff writes:
> On Fri, Aug 18, 2000 at 10:12:02AM -0500, Christopher J. Madsen wrote:
> > foreach $_ $index (@array) { ... }
> >
> > It's only 3 characters, and it makes for a nice consistant syntax.
>
> Yep, but it might also be a source of confusion too. There's no way
> to help the programmer realize that they've screwed up when they do.
>
> for $index (@array) {
> print "$_ is at position $index\n"; # Oops!
> }
>
> In this example, the programmer may realize his mistake when he sees
> " is at position 0", but in the real world, the body of the loop may
> be *much* more complicated. How do we help the programmer when he
> screws up?
I guess I just don't think that would be a very common mistake. The
index is stored in the second variable after foreach. If there's only
one variable, it's not the index, it's the element.
--
Chris Madsen http://www.trx.com [EMAIL PROTECTED]
TRX Technology Services (214) 346-4611
- 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
