DEV Community

Discussion on: Should a modern programming language assume a byte is 8-bits in size?

 
mortoray profile image
edA‑qa mort‑ora‑y

A few notes, related to Leaf, for this discussion:

  • I intend on doing over/underflow checks by default (unless turned off for optimization). Thus an overflow will result in an error.
  • I will provide logical ranges for values, like integer range(0,1000) so you can give real world limits to numbers and let an appropriate type be picked.
  • Arbitrary precision is extremely costly compared to native precision. A fixed, but very high, precision, is not as costly, but doesn't solve anything. On that note, you can do integer 1024bit in Leaf if you want.
  • Leaf constants are arbitrary rationals and high precision floating points during compilation. Conversions that lose precision (like float -> integer) are also disallowed. This helps in several situations.
Thread Thread
 
vinaypai profile image
Vinay Pai

So you pointed to a bunch of bugs caused by a lack of range checks. Your solution to avoid creating another bug is to... add a range check. Brilliant! You have indeed made your point.