DIP: add Bit Fields

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Fri Mar 8 19:38:42 UTC 2024


On 09/03/2024 8:28 AM, Walter Bright wrote:
> On 3/8/2024 1:02 AM, Arafel wrote:
>> In that case, why not have the best of both worlds and have 
>> `extern(D)` (the default, well-defined, perhaps 
>> `std.bitmanip`-compatible) and `extern(C)` bit fields, like with 
>> classes and C++?
> 
> Not a bad idea, but it may be confusing which one is in play, as the 
> extern(C) can be far removed from its effect.

Since fields do not currently have block behaviors for externs, doing 
this would be a new pattern in the language usage.

Otherwise per encapsulation/scope setting of extern may be required. 
Which is already used, but as it would be required this is new.

Either way as per my original comment it needs to be argued which ever 
way you go, the cost of implementing our own layout shouldn't be an 
issue considering how many others will be needed > 1.

I would love to see this replace the library solution.


More information about the dip.development mailing list