lua-users home
lua-l archive

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

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
|    | scintillating, many fauceted scarlet emerald..."
| ( | --- Jim Theis, _The Eye of Argon_ (spelling
+- --+ original)

Attachment: signature.asc
Description: OpenPGP digital signature