lua-users home
lua-l archive

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


On 11/14/2012 12:40 AM, Roberto Ierusalimschy wrote:
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.

maybe ":" as single token, in NL kids at schools start with (positive) integers and the : is used as division symbol learn division (but anyway, // looks visually ok too)

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.

Does 1.0 represent an integer or float? or is it:

1.0 * 123 => float
1   * 123 => integer

(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.)

indeed

just curious: what is the expected impact on memory and speed?

Hans

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
    tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------