D as an extension language for C

Quirin Schroll qs.il.paperinik at gmail.com
Wed May 24 14:28:52 UTC 2023


On Tuesday, 16 May 2023 at 13:36:46 UTC, Adam D Ruppe wrote:
> On Tuesday, 16 May 2023 at 11:04:53 UTC, IGotD- wrote:
>> The only thing I can think of that isn't supported are 
>> bitfields. The question is if this could have been solved with 
>> meta programming.
>
> ImportC can do C bitfields, but since they're layout is 
> undefined it is useless anyway.
>
> (Walter also copied importC's awful bitfields into D, but I 
> hope that mistake is reverted.)

Yes, the syntax is awful. It should have been `__vector(bool[n])`:
```d
struct minifloat
{
     __vector(bool[3]) significand;
     __vector(bool[4]) exponent;
     __vector(bool[1]) sign;
}
```

C++ leads the way with `std::vector<bool>` and its packed bits. 😁

No, in all seriousness, `__vector(bool[n])` wouldn’t be nearly as 
bad a syntax as C’s bit-fields. And giving `__vector(bool[n])` 
special semantics is nowhere close to daring.


More information about the Digitalmars-d mailing list