On 19 Dec 2002 at 21:52, Frank Heckenbach wrote:
[...]
Now, we could discuss enums with specified values as a GPC extension. (I know I'm opening another can of worms, but currently there are so many worms around, I hope they'll eat each other ... ;-)
Pascal breeds cannibalistic worms? ;)
The perhaps obvious syntax
type Foo = (a = 3, b = 5);
is not a good idea since it's too close (too much read-ahead required) to:
type Foo = (a = 3) .. True;
Using `value' or `:=' instead of `=' might work, though.
Interesting. There are perhaps many reasons not to do this. But I would certainly benefit from such an extension. People might think that it is not important enough - but when you have thousands of lines of C header to translate, anything that helps is important. However, I don't feel strongly enough about this to be ready to defend it. So those who are ready to pounce can save their energy ;-)
[...]
Maurice Lombardi wrote:
type tHighWord = packed record
One question - do the records need to be packed, or is that just a "good" thing?
[...]
I see - so that is what those colons mean. In this case, the on-going discussions about what to do with this syntax become even more pertinent.
Indeed, that's the only case where specified sizes are really needed in C interfacing.
Generally speaking, perhaps. With respect to the WinAPI, no. Specified sizes are "really needed" all over the place - function parameters, type declarations, function results, etc.
With this in mind, some of my previous comments might become clearer.
As others suggested, packed subranges could replace `Integer/Cardinal/Word(n)' (which includes the present case).
Packed subranges requires specific knowledge of bits and how to fit something within x number of bits. I certainly do not know that. Having to have such knowledge does not contribute to easy or readable programming. As long as there is a straightforward way to specify the bits (and IMO packed subranges are not a straightforward way), then it does not really matter what the syntax is.
This leaves only `Boolean(n)', and as I said, I severely doubt anyone ever uses an explicit bitfield larger than 1 bit with Boolean semantics in C (and if this happens once in a lifetime, the additional `<> 0' in Pascal is not worth the trouble of discussion).
I am not sure that I understand the distinction being made here about booleans. I think it is accepted that the WinAPI expects a 32-bit size for booleans. Whether or not one uses integer or boolean semantics to achieve that has already been well debated. Both are feasible solutions, but one is easier and therefore preferable for those who do have to use the feature. I guess i'ts up to you (Frank) to decide which solution you prefer to implement.
But again, I have no problem with the `Foo(n)' semantics, only the syntax is problematic (for at least 3 reasons so far).
If the choice is between packed subranges and a new, easy syntax, then I vote for the latter. Better still if it could be used in the way that Maurice has shown, in declaring fields of records (instead of having first to declare the type separately).
Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.bigfoot.com/~african_chief/