lua-users home
lua-l archive

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


Am 14.10.2013 09:22, schrieb Dirk Laurie:
2013/10/14 steve donovan <steve.j.donovan@gmail.com>:

Except that there are hundreds of thousands of lines out there that do
'if val' assuming that nil evaluates to false. There's really only two
cases - it's not like C./Python where you have to consider zero as
well.  And languages which think that '' is false rightly deserve our
scorn.

Python considers empty lists, tuples and dicts to be false too, and
in general seems to have a false element in almostt every type.
It's one of those things that divide people into lovers and haters.


How about a metamethod __tobool ?

Then everyone could define him- or herself if and how any Lua type should evaluate to bool in a boolean expression. :-)

Best regards,
Carsten


--
Dipl.-Inf. Carsten Fuchs

Carsten Fuchs Software
Industriegebiet 3, c/o Rofu, 55768 Hoppstädten-Weiersbach, Germany
Internet: http://www.cafu.de | E-Mail: info@cafu.de

Cafu - the open-source game and graphics engine for multiplayer 3D action