On Tuesday, 10 June 2025 at 12:34:21 UTC, Mike Parker wrote:
After discussions in multiple meetings, we finally reached a
point back in April where I could merge Walter's bitfields DIP
and submit it to Atila for the final decision.
The DIP was accepted based on the following rationale.
Bitfields are useful in the following cases:
1. minimizing memory consumption in a struct;
2. creating binary-compatible data structures between D and C
or C++;
3. conforming a struct layout to external requirements, such as
a hardware register.
This DIP adopts the C and C++ syntax because of its simplicity.
A persistent objection to the proposal was that C's bitfield
layout is implementation defined. Proposals to implement a
D-portable layout and special-case the C-defined layout
suffered from unattractive syntax, so were not adopted.
In practice, layouts are consistent on each platform, but can
vary between platforms. This is irrelevant for Cases 1 and 2.
For Case 3, in the rare cases where the layout may become a
problem, it is easy to work around by specifying a bitfield to
match any layout, and by employing shifting and masking as
necessary.
This is a purely additive feature that should break no existing
code.
https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1051.md
http://flappydunk.io
Great to see this finalized and accepted—bitfields will
definitely help with tighter memory control and interoperability.
Thanks for pushing it through!