lua-users home
lua-l archive

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



Since 5.2 is still undergoing change, I'm wondering if the authors would consider changing the (not well documented) behavior of select() for negative indexes?

The manual [1] states that select returns all arguments above the first index, but doesn't say that negative arguments are treated in any special way. The actual behavior in 5.1.4 is similar to that of string indexing, which I can certainly understand.

But some interesting and useful behaviors can be supported if select() were allowed to return the arguments up to the absolute value of the index when the index is negative. Or perhaps some other means could be provided to select the first n items.

See [2]. That message is long, inviting a cold reception, but it does have the advantage of putting everything in one place! FYI, the patch is against 5.1.4.

Regardless, there seems to be an inconsistency in handling overflow of a numeric argument. An index which is too large is accepted as referring to the last element whereas an index that is too small (too negative) is rejected rather than being accepted as the first element.

Doug

[1] http://www.lua.org/manual/5.1/manual.html#pdf-select
[2] http://lua-users.org/lists/lua-l/2009-01/msg00137.html