lua-users home
lua-l archive

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


On Tue, Nov 13, 2012 at 3:05 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 2012/11/13 Rena <hyperhacker@gmail.com>:
>> On Tue, Nov 13, 2012 at 10:42 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
>>> 2012/11/13 Rena <hyperhacker@gmail.com>:
>>>
>>>> Recently I was thinking about how you might add a 64-bit integer type to Lua.
>>>
>>> This is only a pressing question if you need IEEE floats and 64-bit integers
>>> in the same program, otherwise you can build Lua with 64-bit integers
>>> as your `number`.
>>>
>>
>> True, but I really prefer to leave recompiling Lua as a last resort.
>
> How do you envisage accommodating new types without patching
> and recompiling Lua?
>

...that was kind of the point of the original post. Already you have
lua_pushlightuserdata(L, p); this could be as simple as
lua_pushcustomuserdata(L, p, n), which functions the same as
lua_pushlightuserdata except for adding n to the "type" value
(LUA_TLIGHTUSERDATA + n + 1, for n = 0 to some appropriate upper
bound), and having those types be something like union { uint64_t int;
uint8_t byte[8]; } instead of void*. You'd only need the initial
change to add this capability, instead of hardcoding new types into
Lua directly.

-- 
Sent from my Game Boy.