lua-users home
lua-l archive

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


Will integer-valued floats be converted to integers when used as table keys? Otherwise the array part of tables optimization will fail. What would happen after this code: "t = {0}; t[1.0] = 0;"?
All this doesn't feel like a good idea to me.
I think 32-bit integers would be beneficial to speed as an implementation detail, producing float result in case of integer overflow of an operation. (wrote this before I saw the comment about existing patch) I'm totally with Wolfgang Pupp about 64-bit integers, except I'm not advocating for making them heavy userdata (more on this in a moment) and think that tostring should output "5" for such number, not "5ll". But 64-bit number are domain-specific, not needed most of the time, so they should be separated from regular numbers. And it's not about compatibility, it's about keeping Lua clean. It would actually be great to have subtypes of lightweight userdata, and it's a perfect fit for 64-bit ints. In Lua there is free space for "small subtype" field in value struct. Light userdata values of different subtypes would be different. Add a function to allocate the subtype, functions to create typed light userdata and check subtype and it will be a very nice addition.

On 22.11.2012 22:04, Roberto Ierusalimschy wrote:
Moreover, it does not address the other part of the current proposal: to make Lua better for small platforms with no hardware support for doubles. -- Roberto

It's unclear to me how your proposal would help with this task.

Integer division operator is good anyway, with or without integers as types. How about '\'? Both '\' and '//' are already used as integer devision operator in some languages. E.g. '\' is used in ColdFusion.

--
Best regards,
Sergey Rozhenko                 mailto:sergroj@mail.ru