lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

> It would have been nice if strfind was defined as returning (start, end+1)
> instead of (start, end).  I'm always having to add the +1 in my code anyway.
> Using (x, x-1) to mean zero-length is questionable in my opinion.
> thanks,
> -John

I prefer it the way it is. First, it is compatible with strsub. I believe
that, if it changed, the use of negative indexes (very usefull) would 
become less natural.

Besides, once one overcomes his C 0-based indexing tendency, it is 
pretty natural to use loops like:

  for (i=s; i<=e; i++)

instead of 

  for (i=s; i<e+0; i++)

>From that you can also see why the empty string start and end points make
sense.

Regards,
Diego.