this post was submitted on 15 Jan 2025
114 points (93.8% liked)
Programming
17832 readers
107 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities [email protected]
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
It's because the Booleans sometimes are flipped in display-server technology from the 1980s, particularly anything with X11 lineage, and C didn't have Boolean values back then. More generally, sometimes it's useful to have truthhood be encoded low or 0, as in common Forths or many lower-level electrical-engineering protocols. The practice died off as popular languages started to have native Boolean values; today, about three quarters of new developers learn Python or ECMAScript as their first language, and FFI bindings are designed to paper over such low-level details. You'll also sometimes see newer C/C++ libraries depending on newer standards which add native Booleans.
As a fellow vim user with small hands, here are some tricks. The verb
gU
will uppercase letters but not underscores or hyphens, so sentences likegUiw
can be used to uppercase an entire constant. The immediate action~
which switches cases can be turned into a verb by:set tildeop
, after which it can be used in a similar way togU
. If constants are all namespaced with a prefix followed by something unique like an underscore, then the prefix can be left out of new sections of code and added back in with a macro or a:%s
replacement.Seriously helpful thanks! One of my friends working on a G15 restoration project pointed out this notation to be after you did— yet while they use 0 for truth they used 20 for false so not sure were they got the second idea. And your vim tip saved me a bunch of hand ache!
In VisualBasic "true" would be represented as -1 when converted to an int because it's all 1's in twos complement.
By the way, you can use
g~
to get the effects of tildeop without needing to set it.