Hacker News new | past | comments | ask | show | jobs | submit login
Two Minute Tips: The Dark Secrets of Bools (jacobbartlett.substack.com)
14 points by jakey_bakey 11 months ago | hide | past | favorite | 4 comments



> The Swift Bool lives a double-life. The duplicitous struct has just one instance property — a 1-bit integer.

> Think that’s okay? Think again. It isn’t even a real Int!

> It’s a Builtin type, Int1, which maps directly to an LLVM instruction deep in the guts of the Swift compiler.

Seems like the right way to build things.

I'd be surprised if you didn't find the same thing digging into its Int types - are they also not real Int types?


You’re exactly correct, they are also implemented internally as builtin int64 types (ie only useable by the compiler) - or maybe int32 depending on your hardware


Why is the author so upset that a Boolean is a one-but integer? Seems pretty reasonable to me.


The intense disgust is a literary technique / framing device to hammer home that primitives which most devs don’t think about actually have their own implementations




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

Search: