lua-users home
lua-l archive

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


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