lua-users home
lua-l archive

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


On Tue, Nov 20, 2012 at 12:22 PM, Richard W.M. Jones <rjones@redhat.com> wrote:
> On Tue, Nov 20, 2012 at 10:54:53AM +0000, Jerome Vuarand wrote:
>> If you can do with only 53 bits, you can use plain Lua numbers. For
>> file offsets (with byte-size words) for example that covers 8
>> petabytes. Otherwise you have to revert to the same techniques as in
>> C, pass the number in two parts in a table, or as an opaque value (in
>> a string or in a userdata) which limits the manipulation the user can
>> apply, but depending on the situation that may be acceptable.
>
> The code currently expects a string to be passed in [I may change this
> so it can accept either a string or an int], and returns the int64
> converted to a string.
>
> This seems something of a problem with Lua itself.  How would you
> express, say, the exact size in a bytes of a disk volume?  2^53 is
> 8 petabytes, which is easily in range of what is available in high end
> storage now.  I have access to a larger disk array at work.  Not to
> mention that virtual, sparsely allocated disks can be larger even on
> my laptop.
>
> Also we use 64 bit ints as bitmasks in various places.

Yes it is a problem; see another thread here for discussion of adding
a true integer type to Lua as well, which would resolve a lot of
issues.

Note that the luajit ffi http://luajit.org/ext_ffi.html does have
native 64 bit number types, and you could take the code to implement
them in standard Lua from luaffi https://github.com/jmckaskill/luaffi
which was what I was thinking of doing for ljsyscall
https://github.com/justincormack/ljsyscall which I wrote for luajit
ffi first.

Justin