lua-users home
lua-l archive

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




On 29 July 2011 20:21, Lorenzo Donati <lorenzodonatibz@interfree.it> wrote:
Sorry for quoting myself:

On 29/07/2011 21.01, Lorenzo Donati wrote:
[...]


I assume we can relay on that case, but is it feasible to put in the
manual a comprehensive list of where this "implicit 32 bit integer"
problem could bite us?


This seem a case where having some interpreter limits available at runtime would be very useful to write more robust scripts.

I know that I asked for this long ago, and Luiz replied that it could encourage complicated programming.

But still, here I feel we could benefit from definitions like these:

_NUMBER_TYPE = "double"
_IMPLICIT_INT_WIDTH = 32

I know they are ugly, but it's uglier to try to guess them when you run a script with different interpreters (maybe one out of your control, because embedded in another program of which you don't have the source).

-- Lorenzo



vm_details = function()
local env = string.dump(function()end) 
assert(env:byte(6) == 0x00)--if hit then it is not an official Lua release
local number_type
local int_width
if env:byte(12) == 0x0 then
if env:byte(11) == 0x08 then
number_type = 'double'
elseif env:byte(11) == 0x04 then
number_type = 'float'
else
number_type = 'unknown'
end
else
number_type = 'int type of size ' .. tonumber(env:byte(11))
end
return number_type, tonumber(env:byte(8))
end