Re:Gpsd bug may create a 1024 week time warp on October 23
by tialaramex on Monday August 02, 2021 @07:59PM
(#28044240)
This mistake also requires that the assignment operator has a result (and further, that the result can be silently coerced into a boolean for whatever reason)
In both Rust and Swift, this mistake doesn't compile, their assignment operators don't have a result and so it can't very well be true (or false) ‡
‡ Technically the result of Rust's assignment operators is the empty tuple, which is the closest to "doesn't have a result" in the type system. I don't know about Swift.
Re:Gpsd bug may create a 1024 week time warp on October 23
by j0057 on Tuesday August 03, 2021 @12:30AM
(#28045731)
As far as I'm aware, only C and C++ a use for Yoda conditions have.
Re:Gpsd bug may create a 1024 week time warp on October 23
by account42 on Tuesday August 03, 2021 @07:27AM
(#28047937)
Big the C family is. Copied to many languages its quirks have been.
Re:Gpsd bug may create a 1024 week time warp on October 23
by floatingatoll on Monday August 02, 2021 @08:31PM
(#28044433)
That is a stellar point, thank you for this.
Less so for most comparisons, but for equality, it'll throw an error if you're using the wrong operator instead of having unintended side effects.
week = 2180 will set the week to 2180 in a lot of languages.
2180 = week will always throw an error.
So if I want to compare, it's safer to use the form of 2180 == week because if I forget the second '=', the compiler will tell me before I make bigger problems.