I think one of the things we don't appreciate enough about Rust is how it goes out of its way to say "hey! looks like you're trying to use a C idiom. Here's how we say that in our language." Anyway we spell `-1` as `!0`, which is something we may want to tell C programmers.
-
Show this thread
-
Replying to @myrrlyn
!0 is the worst way to spell it imo. Spell it u32::MAX
2 replies 0 retweets 6 likes -
-
Replying to @myrrlyn
Was this tweet using as few keys as possible to ironically make the argument that reducing the number of keys used in an expression at the cost of clarity and readability is a bad argument? If so I agree
1 reply 0 retweets 2 likes -
Replying to @sgrif
taking off my jokes face, or as i guess you could call it, my "bit mask", i think `!0` and `uN::MAX` are each the best in their domains, but they are nevertheless in different domains. if you work with numeric integers, use `MAX`; if you work with bitwise registers, use `!0`
4 replies 0 retweets 9 likes -
I do actually use `::MAX` in
#bitvec, since constants can propagate through traits and literals cannot, but in my concrete code, `!0` more clearly indicates "a register with all bits set", while `::MAX` only indicates "an integer that cannot be exceeded"1 reply 0 retweets 4 likes -
Replying to @myrrlyn
I will always think "ok so it's 1" and then stare and be confused when I see `!0`
1 reply 0 retweets 0 likes -
Replying to @sgrif
yeah this is a very real cost of a language tradition that doesn't have booleans, and/or failed to represent them as `0` and `~0` :/
2 replies 0 retweets 0 likes -
Replying to @myrrlyn
I guess my point is that more generally "all bits set" is not something that represents what you actually mean, even when working at a low level. Even if more often than not, it's actually just a sentinel value, max or all bits is irrelevant, MAX is harder to misunderstand
2 replies 0 retweets 1 like
I think I meant to replace some of those commas with words but ran out of characters. Hopefully you get what I mean
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.