News for hackers. Stuff that matters.
Re:Gpsd bug may create a 1024 week time warp on October 23 by inetknght on Monday August 02, 2021 @07:02PM (#28043778)
> Can someone explain the rationale for writing comparisons in the ordering they're using (e.g., 2180 < week)?

https://en.wikipedia.org/wiki/Yoda_conditions

> it seemed error-prone to not write them the way they'd be spoken aloud

It is written the way it'd be spoken aloud. If you're not speaking it that way then you need to change the way you think. Programming is another language after all.

Re:Gpsd bug may create a 1024 week time warp on October 23 by colejohnson66 on Monday August 02, 2021 @07:35PM (#28044057)
I don't know about you, but "week is greater than 2180" sounds more natural than "2180 is less than week"
Re:Gpsd bug may create a 1024 week time warp on October 23 by inetknght on Monday August 02, 2021 @07:53PM (#28044189)
> I don't know about you, but "week is greater than 2180" sounds more natural than "2180 is less than week"

To you perhaps. To me, I think "if I put both sides on the number line, which way is being questioned? and is that question answered true or false?"

And therefore I almost always do an equals or less-than comparison because that's how I think about the number line: 0 in the center with negatives on the left and positives on the right.

So `if (week < 2048)` is just as valid and easy to think about as `if (!(2048 <= week))`. But then `if (!(2048 <= week))` provides an additional guarantee: that I won't accidentally assign to `week`.