David Green wrote: > Jon Lang wrote: >> Given that it's relatively easy to say "1..^*", I wouldn't mind >> standardizing this so that '*' always refers to the element just past >> the last one, at least when dealing with the standard index. > > I like the DWIMmery, but the more I think about it, for such a little > difference, it seems more worthwhile to be consistent than to be DWIMy. So, > yes, either * always means last+1, and use 1..^*, or make * mean the last > index, and use [*+1] to append.
...and if addressed properly, it can be DWIMmy too. In many ways, saying that * is just off the end of the index range is counterintuitive; it's more reasonable to people who haven't been trained to think in terms of Perl 5's negative indices to think of 0 as being the first element and * as being the last element. And again, there are fewer problems with custom indexing if you go this route. >>> But there is a problem with sparse arrays, isn't there? > > Sparseness is an implementation detail. Arrays all look the same to the > user; sparseness just means perl is smart enough to do > @foo[10000000000000000]=$bar without trying to suck up a zillobyte of RAM. To the extent that that is true, @foo.elems should equal 10000000000000001. -- Jonathan "Dataweaver" Lang