if (x = true) {}
kind of error. Yeah it sucks, but it's not really the language's fault.Not to mention that that large a block of addition is bad code smell to me.
if (x = true) {}
kind of error. Yeah it sucks, but it's not really the language's fault.Not to mention that that large a block of addition is bad code smell to me.
1. Assignments in conditions could be required to be surrounded with an additional pair of parentheses, like this: `if ((x = true)) {}`. GCC with warnings already requires this for C.
2. The assignment operator could be something other than the equal signs, for example, it could be `:=`. Assignment is so different from mathematical equality and beginners to programming trip up on this all the time, it's a shame programming languages copy each other for familiarity and keep this bad design.
3. Assignments in conditions could be banned out right, like Python does.
IMO, the really annoying language faults are the sort of thing that can't be fixed by a simple linter: object keys being converted to strings, the wonky pseudo-classy prototypal inheritance, dealing with libraries that abuse Function.toString or eval, etc.
Imagine a language were assignments were only done via := and comparisons with = or ==. A programmer would never encounter this error.
Modern Ada's a thoroughly nice language; I did a writeup: https://cowlark.com/2014-04-27-ada