On Fri, Jun 12, 2009 at 04:00:10PM -0300, Daniel Ruoso wrote: : Em Sex, 2009-06-12 às 11:52 -0700, Jon Lang escreveu: : > On Fri, Jun 12, 2009 at 11:51 AM, Daniel Ruoso<dan...@ruoso.com> wrote: : > > Ok, There's one thing that is not clear in the thread, which is when an : > > array is multidimensional or not... : > > For instance: : > > @a = (1, 2, 3; 4, 5, 6; 7, 8, 9); : > > Will produce a flatten array, because list assignment causes flattening, : > > so the dimensionality was lost. : > Right. I should have said: : > @@a = (1, 2, 3; 4, 5, 6; 7, 8, 9); : : The important point here is that it means we're dealing with a different : type, so it can actually behave differently, so "@@a.rotate" would : rotate the first dimension only.. : : maybe @@a.rotate(1;1) would mean to rotate by 1 in the first dimension : and by 1 in the second, producing : : (5, 6, 4; 8, 9, 7; 2, 3, 1)
I think captures are a bit of a red herring here. Arrays can be shaped without the @@ sigil, and that is part of its type, so assignment to @a and @.rotate can also do the right thing. The @@ context was originally just a way of declaring a context that turns nested captures into a multidimensional array at binding or coercion time. So @a := @@(1,2,3; 4,5,6; 7,8,9); used to be defined as the same as @a := [[1,2,3], [4,5,6], [7,8,9]]; Treating @@ as a capture sigil would make @@ coercion a no-op. So perhaps @@ isn't the Texas form of a capture sigil after all. Alternately, we leave @@ (or @%) meaning ¢ and instead let some other syntax take over the "pay attention to the capture's structure" semantics from @@. Maybe it's another use for the zen slice: @a = (1,2,3; 4,5,6; 7,8,9); # 1..9 @a[] = (1,2,3; 4,5,6; 7,8,9); # [1,2,3], [4,5,6], [7,8,9] Interestingly, that would mean that @a = 1,2,3; # 1,2,3 3 elems @a[] = 1,2,3; # [1,2,3] 1 elem! much like subscripts assume .[1,2,3] is a 1-dim slice of three elements, not a 3-dim vector pointing to a single element. There's something slightly pleasing about the equivalence @a = [1,2,3]; @a[] = 1,2,3; Larry