News for hackers. Stuff that matters.
Re:Using ‘switch’ to match arbitrary logic instead of string... by Zenst on Monday August 19, 2019 @07:33AM (#20736844)
Very true, then somebody else ends up maintaining the code and gets a ticket to add this feature and chaos plays out.

One thing I learned early on - true and false vary across platforms. Hence I learned to define true and false at the start of the code with realTrue=(1=1) and realFalse=(1=0). As some systems have 1 or any positive value as true, some have -1 as true. It can get messy, bit like endians (big or little) the same holds true for true and false.

Re:Using ‘switch’ to match arbitrary logic instead of string... by VBprogrammer on Monday August 19, 2019 @08:11AM (#20737029)
> Hence I learned to define true and false at the start of the code with realTrue=(1=1) and realFalse=(1=0)

I'm sure the platforms / language you use make this a sensible choice but I'm not going to lie, if I came across that in someones code I'd be screaming WTF at the top of my lungs.

Re:Using ‘switch’ to match arbitrary logic instead of string... by Zenst on Monday August 19, 2019 @10:49AM (#20738207)
I learned to code in the 70's, predating C99 and having to embrace many diverse platforms (we had more than one mainframe maker back then ;).

But nice explanations here: https://stackoverflow.com/questions/17010041/why-define-true...

TL;DR portability