[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: boolean operators
- From: Glenn Maynard <glenn@...>
- Date: Thu, 21 Sep 2006 22:51:26 -0400
On Thu, Sep 21, 2006 at 10:53:34PM +0000, David Given wrote:
> Glenn Maynard wrote:
> > You don't need bitwise operators to get bitwise operations, though. What's
> > wrong, in your case, with having them as functions?
> > netmask = math.or(netmask, 0x000000FF)
> Functions are slow.
Please see Message-ID: <20060921102652.GG23390@zewt.org> for my response
to cases that really do need performance. Adding operators for this seems
akin to adding operators to C for all of sin(), pow() and floor(): it
doesn't scale at all, leading to a much more complicated language. C
has better solutions: inline functions and builtins. The compiler knows
what floor() does, and may even be able to optimize floor(1.5) to the
constant 1.0, and can do that without adding operators to the language.
There are a slew of uses for Lua that could benefit from reducing
overhead in the same way as bitwise ops, and something more scalable
than adding operators for all of them is needed.
> This may seem trivial, but given the way bitfields are commonly used,
> you typically want speed.
Some ways, sure, but I don't think manipulating TCP/IP netmasks and setting
flags for C APIs are good examples of that. It didn't seem like the
particular person I was replying to actually had performance in mind.