[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: string.sub(String,0)
- From: Markus Huber <pulse@...>
- Date: Sun, 25 Jul 2004 23:12:31 +0200 (BST)
Is the return of string.sub(String,0) official defined? Lua returns the
whole string. But in http://www.lua.org/manual/5.0/manual.html this
behaviour is so described that it should return a string with length 0.
"and string.sub(s, -i) returns a suffix of s with length i"
So string.sub(s,-0) should return a suffix of s with length -0
But Lua returns the whole string.
I think the 0 in this way Lua works now is unflexible because a 1
retursn the whole string too. So the 0 makes no sense. On the other hand
the 0 makes sense if I calculate a string start point and the
calculation result is 0.
Next unlogical point:
A string from 0 to 4 returns 4 bytes (but then I expect 5)
A string feom 1 to 4 returns also 4 bytes
If I think more about the 0 its possible an error but in this case it
make more sense to sepnt more flexibility. Lua stands for flexibility.