On Tue, 2002-09-24 at 11:07, Trey Harris wrote:
> In a message dated Tue, 24 Sep 2002, Chip Salzenberg writes:
> > then what about
> >
> > $a = (1)
> >
> > ? And if someone says that I have to write:
> >
> > $a = (1,)
> >
> > then I am going on the warpath. That Way Lay Python.
I would *never* suggest such a thing :)
Seriously, it's not that it's Python-like, but that it's not intuitive
to Perl programmers at all. There's no way to map your brain into that
grammar without re-learning what a list is, and I don't see the reward
being worth that kind of mind-bending.
> *shrug* Regardless of whether we like it, what Larry said is true unless
> and until he invokes Rule 2. And unless he invokes Rule 2,
> C<scalar(1,2,3)> is equivalent to C<[1,2,3]>.
>
> My suggestion is merely that one-tuples lacking the comma cannot be
> constructed with parens (round brackets) and that list-flattening context
> has the effect of voiding top-level round parens (but not square
> brackets).
The crux of the no-parens for lists discussion has been the idea that in
the current state of affairs, square brackets are a pointless tumor on
the syntax of Perl 6. You don't need them, not ever... almost. You can
do:
$x = (1,2,(3,4),(5,(6)))
And everything except for that last C<(6)> will be an anonymous array,
constructed for your viewing pleasure. Of course (again, NOT PROPOSING
ANYTHING, just citing how it is supposed to be now):
$x = [1,2,[3,4],[5,[6]]]
Will do what you intended, but now we're keeping brackets on just for
the single-element anonymous array feature, which is one hell of an
impact on the syntax for such a small feature. Larry's work on Patterns
would seem to indicate a deep disdain for this sort of slop, so I
imagine a future apoc. will address the waste of operators here. I await
it with much faith in the power of authoritarian rules :-)
> push @a, (7,3,2);
>
> would push the elements 7, 3 and 2 to the end of @a, but
>
> push @a, [7,3,2];
>
> would push a single element containing the arrayref [7,3,2] onto the end
> of @a.
>
That doesn't really work. Because now you introduce the case where:
$x = (1,2,3);
@y = (1,2,3);
$z = [1,2,3];
push @a, $x, @y, $z, (1,2,3), [1,2,3];
Behaves in ways that will take hours to explain to newbies, and I assure
you it ain't WIM. Not even a little bit.
--
Aaron Sherman <[EMAIL PROTECTED]>