> Now, I love that the for loop can do both of these things, but the subtlety
> of the difference in syntax is likely, IMO, to lead to very difficult-
> to-find bugs. It's very easy to miss that I've used a comma when I meant to
> use a semicolon, and vice versa. And what's the mnemonic again?

Well, I made two (weak) mnemonics for myself. The first is somewhat 
idiomatic, that @a, @b concatenates the two lists, or, in Perl 5 it did. 
@a;@b doesn't do that, and it's rather easy to see.

The second mnemonic is that I think of doing the two-at-a-time thing as 
traversing sequentially, or horizontally. Parallel seems more vertical. 
And semicolon seems a lot more vertical than comma.

Yeah, they're stretching a little, but I can quickly tell the difference, 
and I haven't written a line of Perl 6 code.

> Is there any way the syntax could be made different? Could the two
> approaches be differently named? Perhaps the first could be C<foreach>, and
> the second could be C<for>, and they could both use commas.

I would say I wouldn't like that. I've always appreciated for and foreach 
being synonyms (in fact, I think well chosen synonyms are one of the keys 
to a highly readable language). So, if the rest of the world is me, you're 
just being paranoid. But we'll see if anybody else disagrees with me.

Luke

Reply via email to