> > 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.
You _can_ write that, but you don't _have_ to. [1], @(1), list(1), or maybe other things will work too. But (1) is not enough in scalar context. On 24 Sep 2002, Aaron Sherman wrote: > 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 comment about [1,2,3] being mnemonic because we use @a[1] to index arrays was an excellent point. Since [1,2,3] works for both $a = [] and @a = [], maybe we should consider dropping the parenthesis instead of the brackets. (And I was the putz that first suggested that brackets might be superfluous.) Of course, that won't stop commas from creating lists. > On Tue, 2002-09-24 at 11:07, Trey Harris wrote: > > 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. >From reading the apocalypses, I think Larry, et al, are aware of this, and I fully expect the situation to be clarified when the next apocalypse comes out. Maybe we should have a pool for the release date? :) > 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. The parenthesis have no effect because they are only grouping. So the only question in my mind is whether @y gets flattened or is treated as a single object. In either case, we can clarify our meaning by writing *@y to force flattening or \@y to prevent flattening. ~ John Williams