Re:Rust for C++ programmers – part 3: primitive types and op...
by Dylan16807 on Wednesday April 23, 2014 @09:55AM
(#7633937)
>where booleans cannot be compared
Sounds like a way to make XOR be a big pain.
Or do you only want to ban comparing to literals? It can make things clearer to write something like "if bool==false" rather than "if not bool", especially when double negatives get involved.
Only ban comparing to literal true? Sure, go for it. But then the language is more complex for no real benefit.
Re:Rust for C++ programmers – part 3: primitive types and op...
by masklinn on Wednesday April 23, 2014 @09:54AM
(#7633927)
Equality might be used for other things, e.g. a map with boolean keys, stuff like that. So I don't think it would be workable.
You could try removing Eq, Ord and TotalOrd from Rust's bool and see what breaks.
I have powerful dislike for code like the future version of the above, i.e.
since that, in my mind's machine, just generates a bool result, which then (in the logic of the code) must be compared to True. If the result of == doesn't have to be compared, then why does some_bool? It's brutally inconsistent and fantastically annoying.Unfortunately, to many programmers it's also second nature to write such comparisons. Gaah. :(