John Williams writes: > On Thu, 2 Sep 2004, Larry Wall wrote: > > A multidimensional array is indexed by a semicolon list, which is really > > a list of lists in disguise. Each sublist is a slice of one particular > > dimension. So > > > > @array[0..10; 42; @x] > > > > is really short for > > > > @array.postcircumfix:[]( <== [0..10], [42], [EMAIL PROTECTED] ); > > I'm a bit surprised. > > If I declare > > method postcircumfix:[] ($self: [EMAIL PROTECTED]); > > Is $object[$yada] the same as > > $object.postcircumfix:[]( $yada ); # which I would expect > > or > > $object.postcircumfix:[]( <== [ $yada ] ); # which surprises me > > If the latter, Why? > If the former, where did the extra magic for arrays come from?
Well, that's just postcircumfix operators are defined. We have to pick some way for the arguments to come in for any operator type we define, and this is just how those work. Defining postcircumfix operators this way allows us to use semicolon slices in hashes and even sub-like calls: method postcircumfix:() ($self: [EMAIL PROTECTED]) {...} $object($foo ; $bar); For multiple argument lists. Coderefs don't do this by default (they don't accept that notation), but other forms of $object() might. BTW, the latter is the same as: $object.postcircumfix:[]( [$yada] ); Since it has no positional section. > Tangential trivial thoughts: > > Can I declare an alphabetic postcircumfix operator? > > sub postcircumfix:ipso...facto ( $left, $inside ) {...} > > Is that even usable, given that no space is allowed before the > postcircumfix operator? Or does this work: > > $foo.ipso 'bar' facto; Yep, that's fine, if very weird looking. Luke