[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Is everything an expression?
- From: Seppl Vorderhörer <Seppl.Vorderhoerer@...>
- Date: Sun, 08 Sep 2013 16:47:28 +0200
Am 08.09.2013 13:14, schrieb Lorenzo Donati:
Well, I like the and/or idiom and I accept the term "hack" only because
it fails when "false/nil" comes into play...
Really?
To write a statement "a and b or c" when you in fact want "if a is
true then use b otherwise c" was one of the weirdest things I've ever
seen so far.
It works, but is very far from being obvious and "human readable".
I think, that Lua has a quite clear syntax in general, but this
construct is the exception from the general case and the term "hack"
describes it very well.
The point is that keywords like and/or that are usually used (and I'd
say by 99% of all programmers seen as) "operations that use conditions
and result in other conditions" are here really misused to not return
booleans but other types.
An expression " a ? b : c " where it's explizitly defined and clear what
happens and what the result is would be way clearer...
(... at least in my opinion.)