[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Extending Lua for multiple light userdata types
- From: Xavier Wang <weasley.wx@...>
- Date: Wed, 14 Nov 2012 08:14:03 +0800
Very good idea, but, shouldn't this can be a sub type just like short
string and long string?
the only new feature is '//'(?) for integer division, I love it, I
just dream it for a long time when I write Lua.
some doubt, why integer overflow just like unsigned in C? does
negative integer exists?
if integer is just a sub-type, then this improve can be added to
Lua5.2. that will be good :-)
2012/11/14 Roberto Ierusalimschy <roberto@inf.puc-rio.br>:
>> 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
>
>
--
regards,
Xavier Wang.