On Wed, Aug 19, 2009 at 1:54 PM, Moritz Lenz via RT < perl6-bugs-follo...@perl.org> wrote:
> > Since the discussion came up on #perl6 if this is really the expected > behaviour, S09 says: > > As the end-point of a range, a lone "whatever" means "to the maximum > specified index" (if fixed indices were defined): > > say @calendar[5..*]; # Same as: say @calendar[5..11] > say @calendar{Jun..*}; # Same as: say @calendar{Jun..Dec} > > or "to the largest allocated index" (if there are no fixed indices): > > say @data[1..*]; # Same as: say @results[1..5] > > > It doesn't mention how the postcifcumfix:<[ ]> is supposed to introspect > those to find out if the WhateverCode object constructed by 1..* needs > to receive self.elems or self.elems-1 as an argument. > > Which is why I CC: p6l to get some ideas or clarification, and if we > want to maintain this DWIMmy but not very consistent behaviour. > I like it the way S09 says it. But there is a problem with sparse arrays, isn't there? S32/Containers (S32-array) says this about elems: > our Int method elems (@array: ) is export > > Returns the length of the array counted in elements. (Sparse array types > should return the actual number of elements, not the distance between the > maximum and minimum elements.) > For arrays, it appears that using end is more relevant: > > our Any method end (@array: ) is export > > Returns the final subscript of the first dimension; for a one-dimensional > array this simply the index of the final element. For fixed dimensions this > is the declared maximum subscript. For non-fixed dimensions (undeclared or > explicitly declared with *), the index of the actual last element is used. > Does that seem usable to y'all? -- Jan