4 ms·
Two Minute Tips: The Dark Secrets of Bools
- wodenokoto 3y agoWhy is the author so upset that a Boolean is a one-but integer? Seems pretty reasonable to me.
- jakey_bakey 3y agoThe 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
- mrkeen 3y ago> 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?
- jakey_bakey 3y agoYou’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