John Williams wrote:
> Jonathan Lang wrote:
> > The only place where it makes
> > sense to wrap is when you define 0th as the final element, making it
> > logical that 0th+1 == 1st and 1st-1 == 0th.
> 
> I don't think 0th is a good name for the final element.  I've never seen
> it used for that.  I've only seen it used as a synonym for the element
> with index 0.  (Which is usually also the 1st element.)  No newbie is
> going to read "0th" and think "last".

Agreed; that's why I'd include "last" for newbies to use.  "0th" as "last"
works only as an extension of "-1st" as "first from last", "-2nd" as
"second from last", and so on; you have positive numbers counting from the
first, and negative numbers counting from next-to-last, leaving only 0th
unused and only last unaccounted for.  

> nth means last in at least some instances (e.g. summation from 1 to n).
> The primary meaning is "any element", but its still better than 0th.
> "last" would be better, but I don't want the homonym term problem with
> loops.  It's also not quite symmetrical with 1st.  nth or zth are better
> symmetry with 1st.

nth and zth are too similar to $n'th and $z'th, and really don't do "last"
any more justice than 0th does.  I'll address the problem of using "last"
for last further down.  

> BTW, there should be no ambiguity between C<postfix:'th> and C<''>,
> because one occurs where an operator is expected, and one occurs where a
> term is expected.  last (=nth) and last (=break) are both terms
> unfortunately.

last (=end of list) would be suitable for use in a very select number of
places: within a list index (i.e., @list[..., last, ...]), within the
"adverbs" of a regular expression (i.e., m:last/.../), or _maybe_ in
association with a stream (i.e., <STDIN>.last) - although I probably
wouldn't bother with the latter.  In none of those places is last (=break)
suitable; as such, disambiguation shouldn't be a problem.  As for the lack
of symmetry with 1st, this could be remedied by adding C<first> as well -
although I wouldn't go any further than that (@list[fourtysecond] is just
_wrong_).  

As I see it, the preferred terminology would be 1st, 2nd, 3rd, 4th, ...
when counting up from the start of the list, and last, -1st, -2nd, -3rd,
-4th, ... when counting down from the end of the list.  0th would be in
there for symmetry with 1st and -1st, but its use would be discouraged in
favor of last.  


=====
Jonathan "Dataweaver" Lang


                
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

Reply via email to