lua-users home
lua-l archive

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


On Thu, 12 Mar 2020 at 19:55, cherue <cherue.lual@fastmail.com> wrote:
> I didn't understand that returning a lua_Integer is the intended behavior for all integers.
> The presence of the "J" conversion option was especially confusing, it seemed to imply
> the presence of unsigned 64 bit integers.
>
> I have two suggestions to clear this up for future users:
> - Error on a set sign bit in the "J" and "I8" conversion options
> - Add a note to the manual section 6.4.2 about this

Section 2.1 (which comes long before 6.4.2, maybe too long?) explains
there's only one type of integer in Lua (the language, not the
interpreter). The mentions of lua_Integer and lua_Unsigned (which are
C types) in section 6.4.2 refer to what's in the binary string (the
argument of unpack, the result of pack), not what's in the values (the
result of unpack, the arguments of pack). These value have to fit
within the compact type set that Lua (the language, not the
interpreter) offers. The only alternative is to stuff the J in a Lua
"float", which preserves the sign bit but drops more than one mantissa
bit. Using a Lua "integer" seems to me like the more obvious choice.