3 ms·
This is also the kind of stuff that you C programmers write bugs with all the time, by mistaking = with ==; to the point where most C compilers these days would
by int_19h 8y ago
This is also the kind of stuff that you C programmers write bugs with all the time, by mistaking = with ==; to the point where most C compilers these days would just flag something like if(a=1) as a warning with default settings.
Really, all this mess is the legacy of poor choice of = and == as operators back in C (or rather, B). Pascal really had it right with the assignment being very distinct from comparison, such that it's pretty much impossible to confuse the two. The sole reason for that design decision in C, so far as I know, was that assignments occur slightly more often than comparisons, and so they wanted it to be a single character. But I seriously doubt that it was worth all the bugs.
- Annatar 8y ago“This is also the kind of stuff that you C programmers write bugs with all the time, by mistaking = with ==; to the point where most C compilers these days would just flag something like if(a=1) as a warning with default settings.” No it isn’t; we’re not beginners. I learned Pascal before I learned C. Hated the retarded := as superflous.
- pseudalopex 8y agoIf that were true, exist Yoda conditions would not.