[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: boolean operators
- From: "Grellier, Thierry" <t-grellier@...>
- Date: Thu, 21 Sep 2006 12:46:10 +0200
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
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
[mailto:firstname.lastname@example.org] On Behalf Of Grellier,
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
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
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
PS: for those interested, I've posted the patch in the list a few months
[mailto:email@example.com] On Behalf Of Roberto
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'
> 'not' instead of '&&', '||', and '!' --- Lua *has* boolean operators.
> But I think you were talking about logical operators, which stock Lua
> have, [...]
Sure. Sorry about the confusion. (I should call them bitwise operators.)