Frank Heckenbach wrote:
Adriaan van Os wrote:
Frank Heckenbach wrote:
BTW, apart from the syntax, the topic reminds me of another thing. For some time, I've had the idea of extensible enum types (unlike with records, there's currently no alternative in GPC, except using integer constants, of course). Even if you have no "forks", that would be useful across modules (where you can't always declare the largest type first, and the other ones as subranges).
Something like this ?
TYPE Enum0 = (e0, e1, e2); Enum1 = (( Enum0) e3, e4)
Perhaps, though I find the nested parentheses a little strange. At least I'd add a comma:
Enum1 = ((Enum0), e3, e4)
But actually, both seem to be very hard to parse (consider a subrange `((Enum0)) .. Foo', so the parser would have to read ahead until after the first `)' to find the difference).
I think such extensions to Pascal are not likely to become generally adopted, and will create many more problems than they solve. Over 20 years ago PascalP included the extension syntax:
arraytype[initindex FOR length]
to describe a subarray. This has been especially noticeable by being totally ignored by the community, although it is a very useful (and compilable and checkable) construct. This was Bob Fraleys idea, and if it survives anywhere else it would probably be in HPs Pascal implementation.
As far as the enums above are concerned, what is wrong with:
TYPE Enum1 = (e0, e1, e2, e3, e4); Enum0 = e0 .. e2;