lua-users home
lua-l archive

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

On Thu, Sep 21, 2006 at 03:28:46PM -0500, Rici Lake wrote:
> 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).

If bit ops only worked for strings, then to work for C use cases there
would have to be easy ways of pushing an integral value onto the stack
as a bit string, having lua_tointeger() work for bitstrings, and
printing bitstrings as numbers. Also conversions from number to string
of bits and back in pure lua would be useful.

> 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'm a C programmer... but I don't see anything else on my keyboard that
is more obvious, since "/" is taken, so // seems as good as anything