Double hmmm.... That would also supplant the lone '*' wart in indexing syntax: instead of saying @array[0..10;*;@x] you could say @array[0..10; !; @x]
Presumably, the '!;' would expand to the scalar undef value, which could be interpreted as "do nothing on this axis", while in the related construct @a=(); @array[0..10; @a; @x] the '@a;' would instead expand to a list ref pointing to the empty list, which could be interpreted instead as "return the null set" -- minimizing surprise if @a is only occasionally empty. (Of course, substitute your favorite postfix unary character instead of '!'; '*' would work just as well...) Quoth Craig DeForest on Monday 10 January 2005 03:56 pm, > Hmmmm... It would be easy to distinguish the slicing cases if it were > easier to distinguish between a number and a list containing just [In > fact, that is more or less how perl5/PDL's arg-list-based slicer ('mslice') > does things.] > > At the top of Synopsis 9, there's a discussion about exactly that: > > @array[0..10; 42; @x] > >is really short for > > @array.postcircumfix:<[ ]>( <== [0..10], [42], [EMAIL PROTECTED] ); > >though in the list of lists form, a bare number is interpreted as if it > > were a list of one element, so you can also say: > > @array.postcircumfix:<[ ]>( <== [0..10], 42, [EMAIL PROTECTED] ); > > I believe that this is Wrong, because the distinction that is being blurred > turns out to be important. Ideally, those two postcircumfix cases should > do different things (slice versus index). > > But you can have your cake and eat it too. If those postcircumfix cases > were really different, one could take advantage of the still-unused postfix > unary '!' (for example) to distinguish: > @array[0..10; 42!; @x] [[ maps to ]] (<== [0..10], 42 , [EMAIL > PROTECTED] ); > @array[0..10; 42; @x] [[ maps to ]] (<== [0..10], [42], [EMAIL > PROTECTED] ); > > Then the default behavior is consistent (semicolons denote lists of lists) > but there is an "escape hatch" that lets you make a list of > scalars-and-lists. > > > > > Quoth Larry Wall on Monday 10 January 2005 11:04 am, > > > On Sat, Jan 08, 2005 at 11:37:06AM -0700, Craig DeForest wrote: > > : I just re-read Synopsis 9, which covers PDL-related actions and array > > : slicing, and came to the conclusion that either (A) there's a hole in > > : the syntax as it is lain out, (B) I lack sufficient understanding of > > : what has been thought out so far, or (C) that part of the language > > : definition isn't finished yet. > > > > I expect C is closest to the mark. :-) > > > > : Is the perl6 expression > > : @a[4; 0..5]; > > : a 1x6 array (probably correct)? Or a 6 array (probably not correct)? > > > > Certainly the former. I don't think dimensions should ever disappear > > accidentally. > > > > : If the former, how do you specify that you want the latter? > > > > I don't know offhand. I see both the lure and the danger of the > > extra parens, so we'll probably not go that route. We could find > > some keyword that destroys the current dimension while supplying a > > scalar argument: > > > > @a[gone(4); 0..5]; > > > > Or maybe we want some notation that is explicitly a null slice with > > a scalar value, maybe something like: > > > > @a[() but 4; 0..5]; > > > > or > > > > @a[():pick(4); 0..5]; > > > > or > > > > @a[4 but dim(); 0..5]; > > > > or maybe even something strange like: > > > > @a[()=4; 0..5]; > > > > But I'm certainly open to other suggestions. > > > > Larry