lua-users home
lua-l archive

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


On 07/25/2016 07:21 PM, Philipp Janda wrote:
Am 25.07.2016 um 17:48 schröbte steve donovan:
On Mon, Jul 25, 2016 at 5:42 PM, Doug Currie <doug.currie@gmail.com> wrote:
condition expression with a comparison operator or a boolean variable.
Otherwise the intention is not clear. Use strong typing, avoid automatic
conversions!

Increasingly I'm tending that way - the amount of magic that can be
crammed into a simple if is worrying.  One thing which would
definitely be a misfeature would be a _bool metamethod.

Why?

I am also not so much a fan of conversion magic. As interesting statements like (a = a or 5) are there is one thing you always have to remember while programming Lua, testing for existence and testing for truth is the same unless you use explicit comparison.

Many other languages have similar problem, in static typed languages you at least know at compile type which kind of test is made.

But in the end it really is a matter of taste, many C++ programmers write if(myPointer) { } while I usually write if if(myPointer != nullptr) { }

--
Thomas