lua-users home
lua-l archive

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



On 24/04/2014 12:20, Elias Barrionovo wrote:
On Wed, Apr 23, 2014 at 2:56 PM, Lukas Prokop <admin@lukas-prokop.at> wrote:
1. Shall inf, -inf and -nan be allowed as indices for strings?

Lua strings are finite sequences of characters (bytes), so indexing
them with infinity, IMHO, should return nil, empty string (like
indexing a nonexistant position) or blow up an error. Indexing with
nan makes no sense at all, so error or nil + msg.
I think it should expand +inf to #str and -inf to 1 (= passing -#str to the function)...

In any case, I do think the current behaviour, though following
perfectly sensible GIGO guidelines, may lead to subtle bugs and
therefore should be changed at the library level.