Tanton Gibbs wrote:

> (7) == 7 
> 
> why?  Otherwise, we couldn't use parens for mathematical expressions

<Evil> But as Luke Palmer pointed about above, this syntax would make
square brackets redundant, so we could now use those unambiguously for
overriding mathematical precedence ... </Evil>

(Sorry about that.)

I had been intending posting that purely as a joke, but the more I think
about it the more I wonder whether there could be something in this.  As
Luke also pointed out square brackets for arrays make sense because they
are also used for array indices.

So if the difference between lists with parens and anon arrays with
square brackets is going away, it may make sense to standardize on the
latter rather than the former.  In other words, lists now use square
brackets.

That frees up parens for overriding precedence:

> (3 + 4) == 7  -- the mathematical way
> (3 + 4) == 1  -- the length of the list ... BAD!

  (3 + 4) == 7
  [3 + 4] == 1

I haven't thought this through properly, so there's a high chance it
won't work.

Function params with square brackets would look really odd, so they've
have to count as 'precedence' rather than 'list' (which is largely true:
Perl allows parens to be omitted from sub calls if the precedence is OK
even when the params are a list).

Assigning a list to an array would look like this:

  my @odd = [1, 3, 5, 7];

So the (comparatively rare) case of wanting to have an array contain an
anonymous array reference in its first element and nothing else would
require an extra set of brackets:

  my @foo = [[1, 3, 5, 7]];

That isn't too bad: the doubled brackets provide a visual clue that
there's two dimensions in the array.

This still seems a bit far-fetched to me, but I don't yet like it less
than the other options ...

Smylers

Reply via email to