CBFalconer wrote:
That is, can the packed subrange form replace the specified-size form in all cases?
Internally, they're handled differently, so I'd have to check carefully if both yield exactly the same types in the end (but if not, it can maybe be fixed).
If so, this might justify dropping `Integer/Cardinal/Word (n)' entirely.
I like that solution. It is in the proper Pascal spirit, and not Cified. To me anything that cannot be cleanly parsed without one-char lookahead doesn't belong (with the usual 'else' proviso).
Unfortunately, that's already not the case in EP:
const a = 1;
procedure P; type Foo = (a); begin end;
procedure Q; type Foo = (a) .. 3; begin end;
So you need 3 tokens lookahead (and arbitrarily many chars, since the identifier `a' could be longer, not to mention whitespace), or some tricks (such as parsing `"(" identifier ")"' as a special construct and deciding later whether it's a single-valued enum type or a parenthesized expression).
However, `Boolean (n)' cannot be done this way. It may be used for interfaces to other languages. But I'm not sure how widespread it is. Maybe we should also drop it (along with `ShortBool' etc.), and use integer types instead (and explicit `<> 0' comparisons or so) ...
What is this construct? You are aware that C99 has the _Bool reserved word, with stdbool.h to define 'bool' as _Bool, and values for true and false of 1 and 0? I think this is now a part of gcc.
The construct is to define a Boolean type which has a certain size. Many C interfaces just use `int' for Boolean values, some (especially in tight structs) also `short' or `char' or whatever. (Maybe this will change in the future, but I think many C programmers are somewhat conservative in requiring newer standards.) So, in GPC you can use `WordBool' to interface to a C type `int' which is used as a Boolean in C.
BTW, I'm adding `CBoolean' in GPC now (that's rather harmless, just another predefined identifier which no maigc properties), to be compatible with C's `_Bool' (but as a Pascal Boolean type).
Frank