On 4/17/02 5:38 AM, "Piers Cawley" <[EMAIL PROTECTED]> claimed:

> I've got the horrible feeling that doing it this way will lead to
> nasty ambiguities in parsing, but if that's not the case then I must
> confess that I prefer this syntax. Especially if you want to do
> something like:
> 
>   for @a, @b ; @c, @d -> $x ; $y {...} # Apocalypse
>   for @a, @b -> $x ; @c, @d -> $y {...}
> 
> I think the second version of that looks cleaner, but neither of them
> is exactly gorgeous.

I have to agree that the second syntax is a lot cleaner for me to read. But
I see two problems with it. First, it breaks the consistency of the user of
the -> operator, since that operator is now a way of declaring the arguments
to the closure that follows it. That is to say, this

  for @a -> $x {...}

Is more or less equivalent to

  for @a sub ($x) {...} # pseudocode

So if you have more than one arrow operator, you're declaring more than one
subroutine closure. The arguments for each -> would go into only one
closure, and it's a syntax error to not follow each one with its own
closure.

The second issue is that this syntax doesnąt appear to support parallel
processing (or mixed processing!) unless you still use different separators
',' and ';'. IOW, in this example:

  for @a, @b -> $x, $y ; @c, @d -> $z {...}

Does the $x go with @a and the $y with @b? Or are @a and @b flattened and $x
and $y take two items at a time? This is the reason for the distinction
between '.' and ';' in the current proposal.

So really, I can't think of a syntax other than the one that Larry has
proposed without either violating the current rules governing the ->
operator or creating new ambiguities.

FBOFW, I think we'll just have to start thinking about formatting the
proposed syntax so that it's easier to read (but obfuscators can still be
happy with cramming it all on one line). To quote Damian:

<blockquote>
One thing that might help is to get yourself into the habit of writing
sequential iterations on a single line:

    for @x, @y -> $a, $b {...}

....and parallel iterations on two lines:

    for @x ; @y
     -> $a ; $b {...}

That generalizes nicely on the very rare occasions that you need to use
both:

    for @x, @y ; @z
     -> $a     ; $b, $c {...}
</blockquote>

And then we just have to be aware that this could be the source of subtle
bugs, and use the formatting to help us spot it.

Regards,

David

-- 
David Wheeler                                     AIM: dwTheory
[EMAIL PROTECTED]                                 ICQ: 15726394
http://david.wheeler.net/                      Yahoo!: dew7e
                                               Jabber: [EMAIL PROTECTED]


Reply via email to