[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: small problem with LuaJIT2 and size_t type on x64 platform
- From: Francesco Abbate <francesco.bbt@...>
- Date: Thu, 5 May 2011 17:49:54 +0200
I was recently testing the dev branch of GSL Shell and I've discovered
a problem related to the FFI utilization with size_t on x64 platforms.
I need to explain before that I have a C struct that declares some
fields as 'size_t' types. When you access one of such fields with the
FFI interface you obtains a cdata than contain a boxed uint64_t type.
The problem is when you try to make a for loop using such a 64bit
number as limit that LuaJIT2 show the error:
'for' limit should be a number
The problem here is that a 64bit number is not accepted by the for
loop. I've read the LuaJIT2 documentation and Mike mentions that in
some cases a tonumber() call may be necessary to convert the 64bit
number to a regular Lua number.
The problem is that if I do that I will uglify my code with a lot of
tonumber() that are also strictly useless on x86 platform.
I was wondering if the semantic of the for loop should not be
(slightly) changed to accept boxed 64bit number as limits. This seems
to be coherent with the overall logic used in arithmetic where mixed
operations are allowed and result is 64bit if at least one of the
operand is 64 bit.
I hope to not bother the list with this very specific question but we
don't have (yet ?) a LuaJIT mailing list :-)