[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Strange Operators (Was: Why I leave Lua)
- From: Dirk Laurie <dirk.laurie@...>
- Date: Mon, 21 Jul 2014 20:09:21 +0200
2014-07-21 18:42 GMT+02:00 Philippe Lhoste <PhiLho@gmx.net>:
> 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.