I have to say that in many (most?) C
-like languages the difference between variable == constant
and variable = constant
will be losing your data. It is not something very Julia
-specific. Some programmers of the past called for something called yoda conditions, that is basically: never do variable == constant
if you can do constant == variable
, this way a missing =
will give you a compilation time error (on most C
-like languages).
Not that I do not think your cautionary tale is not useful (the existence of something like yoda conditionals corroborate it), but it is a little more general problem, and one of the few thing that make me thing if the syntax =
(assign) vs ==
(test) thing was not a major mistake from earlier language designers.