3 ms·
Every time I see those new types, I keep thinking about the missed opportunity way back in the language design, to provide a generic syntax like int<N>, and the
by int_19h 6y ago
Every time I see those new types, I keep thinking about the missed opportunity way back in the language design, to provide a generic syntax like int<N>, and then just gradually add mandatory support for N=64, 128 etc in new language versions as needed.
It's not like it's even some new or radical idea - something like that was the original source of the C syntax for ints. To remind, the actual type names are not "short", "int", and "long", but rather "short int", "int", and "long int" - that is, "short" and "long" are qualifiers, just like "signed" and "unsigned"; it's just that you can omit "int". This all comes from ALGOL 68, where that scheme was explicitly generic - the language spec allowed for arbitrarily many SHORT and LONG before INT (or REAL). Implementations were then expected to use as many as they needed to express the types available on the architecture they were targeting.
Or better yet, the way Ada did it:
x: Integer;
y: Integer range 1 .. 1000;
z: Float digits 10
- adamrezich 6y agozig has this: > In addition to the integer types above, arbitrary bit-width integers can be referenced by using an identifier of i or u followed by digits. For example, the identifier i7 refers to a signed 7-bit integer. The maximum allowed bit-width of an integer type is 65535