[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: boolean operators
- From: Rici Lake <lua@...>
- Date: Thu, 21 Sep 2006 15:28:46 -0500
On 21-Sep-06, at 2:44 PM, Luiz Henrique de Figueiredo wrote:
Operators would make things more convenient, but I'd be OK
with having a bitwise operations library...
I think the real point of Roberto's original question was how bitwise
operations would work, be they operators or library functions. More
precisely, should bitwise operations work only over integers (what you
"2.5 | 1" mean?) or should they work over strings (which would then be
seen as bit arrays)?
My problem with operating over integers is that it limits the size of
a bit sequence to a smallish and possibly too small value (it might
be 23, for example) without providing any alternative if that value
is too small for the application. So I'd vote for strings, whose
size is more or less unlimited and not affected by an unrelated
compile-time configuration (the definition of what a lua_Number is).
Regardless of bitwise operators, I would vote strongly in favour
of an integer divide operator, to go along with 5.1's remainder (%)
operator. At the risk of alienating C++ programmers, I'd suggest
that integer divide be spelled "//". It's precise definition
would be: a // b ==> (a - a%b) / b
I don't regard that as a bitwise operator (although obviously it
could be used to implement certain bitwise operators) but rather
as a completion of the numeric suite.