4 ms·
For those not familiar with Ada and bit representations, the compiler is exploiting the fact that types in Ada can have constraints that limit their size. T1 i
by henrikeh 6y ago
For those not familiar with Ada and bit representations, the compiler is exploiting the fact that types in Ada can have constraints that limit their size.
T1 is a type of integer ranging from 16 to 19 (inclusive). Thus, it can only be four distinct values (16, 17, 18, 19). Two bits is enough to represent these four distinct values and thus the binary representation of the type (in record R) can be reduced to 2 bits.
- guerby 6y agoI heard that the only reason Ada had an "Integer" type as opposed to just have range types with user provided bounds was because of String index needing it - String is just a standard array of character in Ada.
- renox 6y agoAda is older than Unicode..
- noneeeed 6y agoThe type system in Ada was always so nice to use, and it was incredibly useful when using SPARK to really constrain the bounds of your types and make the runtime exception freedom proofs easier. I miss working in Ada, but I don't really miss working on those kinds of projects.