[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Extending Lua for multiple light userdata types
- From: Roberto Ierusalimschy <roberto@...>
- Date: Tue, 13 Nov 2012 21:40:39 -0200
> This conversation started in IRC and I fully agree with Rena which
> will come as no surprise as I have said this before. It is 2012 and
> yet Lua has no access to a 64 bit int(in fact from the C API point of
> view it was even considered to remove the default lua_Integer as a
> typedef for ptrdiff_t ), before too long the majority of people will
> not care about 32 bit systems and even arm is getting a 64 bit
> version, when will Rio Lua have a 64 bit int? When will we be able to
> sanely do bit operations on 64bit types without resorting using
> strings *?
I have been playing a little with the idea of introducing an integer
type in Lua. I have intended to present some initial thoughts in the
workshop.
The overall idea is quite simple. There will be two kinds of numbers,
integers and floats. All operations except division result in an
integer if both operands are integers and in float otherwise. There
will be two divisions: float division (the usual '/') always have
a float result, integer division ('//'??) always have an integer
result.
Except for overflows, all operations have the same results
independently of whether operands are represented as floats or
as integers; but there is no automatic conversion on overflows:
operations with integers should overflow like unsigned integers
in C.
(So, the fact that a number is represented as an integer or as
a float is explicit and visible to the programmer, but for most
mundane tasks this distinction is irrelevant.)
-- Roberto