lua-users home
lua-l archive

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

2014-07-21 18:42 GMT+02:00 Philippe Lhoste <>:

> Choosing == as equality, and allowing = to have a value were a poor
> combination, as many beginners forgetting one = wrote tests like:
> if (a = b)
> or even
> if (a = true)
> which is legal even in Java!

We're straying off-topic, as this is no longer Lua, but I cannot
let this pass.

The above code is legal in C, granted, but good compilers have
been giving warning messages in that situation for ages.

In gcc you have -Wparentheses, but beginners should be taught
to compile everything with -Wall. Most beginner mistakes are
caught by that. In fact, I count myself a beginner as far as
perpetrating those is concerned, evern though I wrote my first
C code 30 years ago.