r/ProgrammingLanguages • u/Nuoji C3 - http://c3-lang.org • May 03 '26
Blog post Unsigned Sizes: A Five Year Mistake
https://c3-lang.org/blog/unsigned-sizes-a-five-year-mistake/
91
Upvotes
r/ProgrammingLanguages • u/Nuoji C3 - http://c3-lang.org • May 03 '26
View all comments
Show parent comment
3
u/Tasty_Replacement_29 Bau May 03 '26
For my language, I do not support unsigned types: there are just too many edge cases and security issues with unsigned. Not supporting unsigned also simplifies the language. Unsigned types sound simple, but they are not. There are unsigned _operations_ (eg. right shift and division), but for these cases you can just have separate, explicit methods. That is what Java does for most types (there's "char" which is unsigned). And LLVM does not make a distinction between signed and unsigned integer types.
> it would remove the need for runtime checks
> integer ranges similar to Ada
Yes, my language supports this, to avoid array bound checks:
This means
iis between 0 (inclusive) and the length of thedataarray (exclusive). For most practical problems, a range is enough; sometimes it would be nice to have "not 0", to prevent division by zero (my language requires a check for division). I guess the syntax for this could bei := 1 .. -1, but it does look a bit weird for beginners.