lua-users home
lua-l archive

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


> if the "float with integer values are converted to integers" is
> conserved, then i'd guess that {[1.0]=true} is exactly the same as
> {1]=true}.
> 
> so, i'd expect next({1]=true}) returns 1 and next({[1.0]=true}) would
> have to be the same, unless it kept the original float key.

The point is exactly the "float with integer values are converted to
integers" rule. It only holds for table keys. If I do

t = {[1.0] = 1.0}
a, b = next(t)

Then b will be 1.0, but a will be 1 (an integer).


> And if Lua gets an integer subtype, it would be natural to return
> array indexes as integers.

Remember that Lua has no such thing as "array indexes", only table keys.
If you have a set of real numbers, some of those numbers may be subtly
transformed into integers. (More often than not this transformation will
be irrelevant ;)

-- Roberto