lua-users home
lua-l archive

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


Please bear with me.  I'll try to keep the discussion productive.
And I think I found a solution that is less "quirky".

Please execute this code:

    for i=-4,5 do
      print( i, ("abcd"):sub(i) )
    end
    print "---"
    for j=-5,4 do
      print( j, ("abcd"):sub(1,j) )
    end

I think its not hard to see that the 5th output line is not "in sync".

The following proposal would fix this and has no influence on any 
other string.sub result, where i~=0.

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.


   Jörg