Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

And there are different version of 'dirty trick' perception too. Sometime what people perceive as 'dirty trick' is just normal use of the language while the muggles want to talk baby talk all the time.

For example, having to explain the functional use of 'x = !!variable' to a C programmer. There are many like that.

Sometime you just have to decide to raise the bar a little...



I used !! for decades, but since C'99, I've recommended "bool x = variable" or "(bool) variable".


The reason I would prefer !! (or != 0) is that there are far too many err, non-bool bools. Even if you know for sure it's the stdbool.h bool, the next reader might not be aware -- presuming that when you do this you care about the distinction (otherwise I agree that the cast is fine).




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: