lua-users home
lua-l archive

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


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. I
like to write my code as much in pure Lua as possible, and having it
depend on a custom version of Lua would bother me. Especially, when
you have a custom Lua, you often need to recompile all the C libraries
you use as well to work with it.

There's a patch on the wiki somewhere that adds an "integer" type and
a bunch of bit operators. It's fairly invasive and has a few nasty
bugs, but it shows how new primitive types can be added. IIRC the VM
defines 9 of them before the "heavier" types (that need to be
allocated and collected), so if you allowed for 7 custom types, that
makes for a nice round number, and should probably be plenty. (But I
wonder how the VM encodes type information; maybe there's room for
many more?)

-- 
Sent from my Game Boy.