On Tue, Apr 16, 2002 at 06:17:24PM -0700, David Wheeler wrote:
> In Exegesis 4, Damian writes:
>
> <blockquote>
> It's important to note that writing:
>
>
> for @a; @b -> $x; $y {...}
> # in parallel, iterate @a one-at-a-time as $x, and @b one-at-a-time as
> $y
>
> is not the same as writing:
>
>
> for @a, @b -> $x, $y {...}
> # sequentially iterate @a then @b, two-at-a-time as $x and $y
> </blockquote>
>
> 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?
Personally I really hate the use of the semicolon here - it's
counter-intuitive to everything you expect from semicolons in the 'C'
stable of languages (and English too) - ie my brain groups the terms in
for @a; @b -> $x; $y {...}
like
for [@a]; [@b -> $x]; [$y] {...}
rather than
for [@a; @b] -> [$x; $y] {...}
Maybe we should have something like
for @a -> $x; @b -> $y {...}
Instead.
This has the advange of being writeable as the following for clarity:
for
@a -> $x;
@b -> $y
{
....
But hey, what do I know - I'm not a linguist or language designer :-)
--
But Pity stayed his hand. "It's a pity I've run out of bullets", he
thought. - "Bored of the Rings"