Larry Wall wrote: > David Green wrote: > : I actually found things I liked in pretty much all the suggested > : alternatives, but none of them reached out and grabbed me by the > : throat the way "nth" did. It just seems more Perlish. > > Yow. Presumably "nth" without an argument would mean the last.
If it means the last, why not just use C<last>? It's only one character longer, and its meaning can't be mistaken or confused. So @ints[1st..last] means @ints[*] There is the question about what C<last+1> would mean; intuitively, moving forward from the end takes you into limbo; but I can see an advantage in wrapping things around such that last+1 == 1st, and 1st-1 == last. You could even go so far as to allow something like postfix:'th for whole number scalars, so that $n'th == last + $n. This would imply that 0th == last, that -1st == last - 1 (or "next to last"), and that -3rd == last - 3 (or "third from last"). While the idea that 0th == last is counterintuitive to me, the idea that negative ordinals correspond to offsets from the last element seems rather nice. All in all, this salvages the perl5 $ints[-1] notion, albeit requiring a +1 adjustment - or this could be translated as @ints[1st-1] (a bit bulkier, but more legible). Would we be able to extend this notion? That is, would the following be viable: @ints.shape[0].1st # returns the index that corresponds to 1st for dimension zero Regardless, the following _would_ be viable: @ints.shape[1st] # returns information that corresponds to the first dimension And that's worth a lot. -- Where else could ordinals come in handy? They're already being used in REs, but I'd recommend expanding the usage there to include C<last> and possibly C<$n'th> as well as C<1st>, C<2nd>, C<3rd>, etc. Where else? Would there be any use for C[<STDIN>.3rd], frex? ===== Jonathan "Dataweaver" Lang _______________________________ Do you Yahoo!? Win 1 of 4,000 free domain names from Yahoo! Enter now. http://promotions.yahoo.com/goldrush