I believe that the decision of having a =
and ==
was an error of the past, but trying to go against it now would be another error, at least for Julia (that values the similarity with Matlab and other languages).
Julia greatly minimizes the problem by only allowing Bool
in the if
clause. In your typical C/C++ code, lots of equality comparisons are between integers and most integers are allowed in an if
clause, so a x = 5
is not an error but a much worse silently bug. The Yoda Conditions were proposed to minimize the effects of the problem (yet, they only help if one side of the comparison is a literal or constant).
You clearly are not alone, I have answered someone with a similar problem in the past. In their case, the problem was that even if the code results in an error, you lose the value of the overwritten variable, what is a bother when you are working with Jupyter and the like.