[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: boolean operators
- From: David Given <dg@...>
- Date: Wed, 20 Sep 2006 21:50:31 +0100
Roberto Ierusalimschy wrote:
> Sam Roberts wrote:
>> Other than lua doesn't have the C boolean operators (&&, ||, !), which
>> I keep forgetting [...]
>
> May I ask you (and others) why you need boolean operators in Lua? (This
> is not a rhetorical question. I really want to know what uses boolean
> operators may have in Lua.)
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, and I find a major omission. All my Lua projects use a version of the
interpreter with the logical operator patch. While it's perfectly possible to
use Lua-ish idioms to avoid the need from them, as soon as you start having to
deal with the outside world you start having to cope with bitfields, because
most C libraries use bitfields for flag sets, and stock Lua handles bitfields
extremely ungracefully. (Have you tried testing for a set bit in stock Lua?
It's not pretty.)
--
+- David Given --McQ-+ "Gaping from its single obling socket was
| dg@cowlark.com | scintillating, many fauceted scarlet emerald..."
| (dg@tao-group.com) | --- Jim Theis, _The Eye of Argon_ (spelling
+- www.cowlark.com --+ original)
Attachment:
signature.asc
Description: OpenPGP digital signature