Menu

C3
📰
0

C3

c3-lang.org·c3-lang.org·about 1 month ago
#ZPuXNtut
#x3c#unsigned#signed#sizes#length#article
Reading 0:00
15s threshold

A quick note for readers who don’t follow C3: it’s a systems language in the C tradition. Specifics below are C3’s, but the tradeoffs apply to any language that has to pick a type for sizes and lengths. C3 is moving to signed by default, but why are we doing that? Isn’t unsigned more correct for sizes at least? Let’s try to answer that. The bugs of unsigned Since the early days, C3 has been using unsigned sizes. And while the name of the unsigned type changed over time – from “usize” to “usz” (after the unification with the uptrdiff type) – its position as the default has been unchallenged. However, unsigned has known pitfalls, the most well known being: for ( uint x = 10 ; x >= 0 ; x -- ) // Infinte loop! { ... } In fact, that bug is so easy to run into that C3 explicitly rejects x >= 0 for unsigned types outside of macros. Another classic C bug is: uint a = 0 ; int b = - 1 ; if ( a > b ) { ...…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More