On Sat, Oct 1, 2016 at 1:58 AM, Hisham
<h@hisham.hm> wrote:
> PS: My personal favorite would be to just error() if the starting index was
> 0. Would help catch tons of off-by-ones.
For what is worth, I don't remember _ever_ having had trouble with the
0 index in string functions, or do I remember people posting about it
on the list, so I've never seen these "tons of off-by-ones" in
practice.
Simple task "get suffix of length N" requires using additional handling of the case "if N==0" .
BTW, such errors (using :sub(-N) without checking for N~=0) may stay undiscovered in really existing code.
I believe people never relied on currently implemented behavior of ":sub(0, k)" as this logic is very inconvenient for use.