lua-users home
lua-l archive

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


On Tue, Feb 12, 2013 at 5:37 PM, Richter, Jörg <Joerg.Richter@pdv-fs.de> wrote:
> As already noted the index 0 can have two different meanings.  One is
> the position left of the first character (1). The other one is the position
> right to the last character (2).
>
> Currently both i and j use the definition 1. The example above would
> be "sound" again, if i uses definition 2 and j keeps on using definition 1.

+1.
I have had "many happy minutes of debugging" because of unexpected
behavior of suffix extracting.
i=0 should be interpreted as "after last symbol" for suffixes' sake
j=0 should be interpreted as "before first symbol" for prefixes' sake
This quirk is more desirable, all special cases: sub(-0,0), sub(-0),
sub(1,0) becomes predictable.

IMHO, sub(0) should be the same as sub(0,-1) - both should return empty string.
I never needed sub(0,j) for prefixes.
Can anybody give an example from real life code
where it was more convenient having ('abcd'):sub(0,4)=='abcd' ?