lua-users home
lua-l archive

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


On 2012-11-13 4:09 PM, "Coda Highland" <chighland@gmail.com> wrote:
> I acknowledge that there's an exception to be made for 64-bit ints, as
> they can't be exactly represented as doubles and you'll generally be
> using them for things besides numeric computation (bitmasks for
> example). But I think that this one exception isn't worth trying to
> add an entire new architecture for "non-pointer lightuserdata of an
> arbitrary number of static types" when most of Lua's demographic isn't
> going to care about it. It seems like unnecessary complication.

Well, 64-bit integers would be just one use. Another advantage would be for multiple libraries to use separate userdata types, each with their own metatables. Or you could have a "float" type, if you're working with a program that doesn't understand doubles. Or any type of data you need to manipulate quickly, as long as it fits within 8 bytes, you can avoid the memory management overhead.

As for being a complication, I don't think it would take more than a few lines added/changed. Add a couple more items after LUAT_USERDATA, patch the light userdata related code to consider all of those types userdata instead of just the one, and add functions to get/set userdata that add an offset to the type. I'll see if I can make a patch, but I'm not too familiar with the lowest levels of the VM.