lua-users home
lua-l archive

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


Oh yes I forget to mention, that these bitwise operators in patch are
overloadable, thus providing a mean to better support interface
exposition with swig and tolua. And well I've used them to define higher
abstraction construction (modeling "tasks" fork and join to specify
concurrent scenarios)

And then this is bound to the max integer that lua_number allows. (So it
echoes then to the debate shall lua have int as a native type...).
Hopefully I'm manipulation 32bits addresses so far, so that this patch
is enough.

-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Grellier,
Thierry
Sent: Thursday, September 21, 2006 12:34 PM
To: Lua list
Subject: RE: boolean operators

OK, well let's say why I use a patch for bitwise operators on lua 5.1.1.

I write traffic generators generating requests including addresses. That
is I often apply a mask on the address to bind it to a range. I could do
a 
if < base+range then restart from base, but this is many opcodes, and
lead even to make a function (hence a call).
But this is not only range I deal with, there is also address alignment.
For example I generate random addresses, then bound them to a range,
than align the address on memory (with clearing last bits, either a
shift or another mask). Again this is feasible with language, but
expensive.
Then I deal with responses, where it is still less memory expensive to
preserve them as numbers with bitfields and limits conversion needs.

Maybe this is not mainstream usage, but still when you want to use a
script language to test a protocol, I think this is a stopper not having
these operations. 

PS: for those interested, I've posted the patch in the list a few months
ago.

-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Roberto
Ierusalimschy
Sent: Wednesday, September 20, 2006 10:52 PM
To: Lua list
Subject: Re: boolean operators

> Actually, I think he was just talking about needing to use 'and', 'or'
and
> 'not' instead of '&&', '||', and '!' --- Lua *has* boolean operators.
> 
> But I think you were talking about logical operators, which stock Lua
doesn't
> have, [...]

Sure. Sorry about the confusion. (I should call them bitwise operators.)

-- Roberto