[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Next Version of Lua?
- From: Asko Kauppi <askok@...>
- Date: Wed, 10 Jun 2009 20:47:34 +0300
On the bitwise operations discussion:
If LNUM integer patch would be adopted, it would be natural to define
the bit operations with 'lua_tointeger()' and giving an error if a
value is not an integer.
Personally, I am of the opinion that bitops are for enums and not for
numbers. But there is no support for enums to Lua; thus, add enums
first and rethink bitops then.
(But I do feel like Cato on this one....)
Jim Mellander kirjoitti 10.6.2009 kello 19:51:
Olivier Hamel wrote:
Roberto Ierusalimschy wrote:
Oh. Well. Yah, you won't be getting very far with bitwise ops on
Roberto said they (inner Lua dev group) weren't happy with any
implementation of bitwise operators, it would be helpful to know
what they are not pleased with so we may propose alternate
My dream was bitwise operators that make sense for floating numbers,
like shifts and negation do. But I gave up.
I suggest that floats be cast to ints (or whatever) and then the ops
performed on them. It's common knowledge you won't be getting bitwise
ops on floats natively/naturally unless you add some (a lot) of magic
powder to the mix with a slice of lemon. But even there, I don't
the idea of bitwise ops can ever EVER apply to floats, since their
internal representation does not match that of a 'simpler' number
char/short/int/etc... That said, I had in mind to use bitwise ops on
whole numbers anyways...
Have we considered adding fixed point precision numbers?
My 2nd favorite language (awk as implemented in gawk), which also
double as the numeric type, takes the following tack when doing
"For all of these functions, first the double-precision floating-point
value is converted to the widest C unsigned integer type, then the
bitwise operation is performed. If the result cannot be represented
exactly as a C double, leading nonzero bits are removed one by one
it can be represented exactly. The result is then converted back
C double. (If you don't understand this paragraph, don't worry about
Incident Response Manager
Computer Protection Program
Lawrence Berkeley National Laboratory
The reason you are having computer problems is:
Daemon escaped from pentagram