|
Technically speaking, a purist might even argue that ("a"):sub(1,3) should result in "aaa" (e.g. me). Or that ("abc"):sub(1,4) should result in "a".
Note how select, strings and files have no meaningful concept of negative indices - they're exceptions. Thus, handling negative indices exceptionally makes sense. But you should still aim for consistency wherever possible.
I don't know what the Lua devs think. But it seems they do everything to keep things consistent, only applying exceptions in exceptional circumstances.
And don't forget, it'd also require a change to string.find,string.find, string.gsub, string.gmatch and string.match all take a starting index, which can be negative.
string.gsub, string.gmatch, string.match, string.byte, etc
basically anything that takes an index.
Yes, "string.byte" should be modified the same way as "string.sub" as it uses the same rules for specifying an interval of indexes.
But there is absolutely nothing nothing to change in implementations of string.find, string.gsub, string.gmatch and string.match.