lua-users home
lua-l archive

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


> And the reason why -i does work for i<=0 if you define str:sub(0,-1)
> as the empty string, is that the original definition stays continuous
> at a=5 if str:sub(5,b)=str:sub(4,b). So your definition requires 0
> to alias to 5. That would be interesting (for example, str:sub(-4,0)
> would also be the whole string) but it is not the choice made by the
> Lua designers.

I'm not sure I follow you. My proposal was only for the j=nil case.
It does not have to behave like j=-1, right?

But are you sure that for consistency's sake ("abcd"):sub(-4,0)=="abcd" 
would follow? i=0 and j=0 does not have to mean the same position.

 
   Jörg