www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - bit fields

reply Dom DiSc <dominikus scherkl.de> writes:
Hello.

Bit fields were introduced in 101.0, but searching for them 
yields as first results:

"D does not support bit fields. If needed, they can be emulated 
with shift and mask operations, or use the std.bitmanip.bitfields 
library type."

"Bit fields are supported with the bitfields template."

and

"ImportC - There are many implementation defined aspects of C11 
bit fields. ImportC's behavior adjusts to match the behavior of 
the associated C compiler on the target platform."

But no mention that they are now available. Also the spec doesn't 
describe them.
Have they been removed again with 102.0 ?
Feb 07 2023
next sibling parent Adam D Ruppe <destructionator gmail.com> writes:
On Tuesday, 7 February 2023 at 14:27:16 UTC, Dom DiSc wrote:
 Bit fields were introduced in 101.0, but searching for them 
 yields as first results:
It is a preview switch in there (and one that should never be allowed to remain, it is an absolutely awful and near totally useless design). -preview=bitfields is still in the code right now.
Feb 07 2023
prev sibling parent reply Nick Treleaven <nick geany.org> writes:
On Tuesday, 7 February 2023 at 14:27:16 UTC, Dom DiSc wrote:
 But no mention that they are now available. Also the spec 
 doesn't describe them.
The spec PR was never merged: https://github.com/dlang/dlang.org/pull/3190
Feb 07 2023
next sibling parent Dom DiSc <dominikus scherkl.de> writes:
On Tuesday, 7 February 2023 at 16:21:44 UTC, Nick Treleaven wrote:
 On Tuesday, 7 February 2023 at 14:27:16 UTC, Dom DiSc wrote:
 But no mention that they are now available. Also the spec 
 doesn't describe them.
The spec PR was never merged: https://github.com/dlang/dlang.org/pull/3190
Ok, thanks.
Feb 08 2023
prev sibling parent reply Dmitry Ponyatov <dponyatov gmail.com> writes:
 The spec PR was never merged:
 https://github.com/dlang/dlang.org/pull/3190
Is any chance that a few years later D will adopt packed union/structured with bit fields, slicing and formatting (Erlang-like maybe) ? I see D can be intensively used in embedded and telecom application, where bit ops is definetely required.
Oct 08 2023
parent reply Imperatorn <johan_forsberg_86 hotmail.com> writes:
On Sunday, 8 October 2023 at 08:22:20 UTC, Dmitry Ponyatov wrote:
 The spec PR was never merged:
 https://github.com/dlang/dlang.org/pull/3190
Is any chance that a few years later D will adopt packed union/structured with bit fields, slicing and formatting (Erlang-like maybe) ? I see D can be intensively used in embedded and telecom application, where bit ops is definetely required.
Same
Oct 08 2023
parent reply Bruce Carneal <bcarneal gmail.com> writes:
On Sunday, 8 October 2023 at 15:52:34 UTC, Imperatorn wrote:
 On Sunday, 8 October 2023 at 08:22:20 UTC, Dmitry Ponyatov 
 wrote:
 The spec PR was never merged:
 https://github.com/dlang/dlang.org/pull/3190
Is any chance that a few years later D will adopt packed union/structured with bit fields, slicing and formatting (Erlang-like maybe) ? I see D can be intensively used in embedded and telecom application, where bit ops is definetely required.
Same
Do you have issues with the earlier alternative? https://dlang.org/phobos/std_bitmanip.html#bitfields I use and like this one quite a bit. The new bitfield variant *might* be important for C interop? I'm not in embedded development at the moment but if I went back there I'd prefer the original D bitfields for any new development.
Oct 08 2023
parent Imperatorn <johan_forsberg_86 hotmail.com> writes:
On Sunday, 8 October 2023 at 16:14:15 UTC, Bruce Carneal wrote:
 On Sunday, 8 October 2023 at 15:52:34 UTC, Imperatorn wrote:
 On Sunday, 8 October 2023 at 08:22:20 UTC, Dmitry Ponyatov 
 wrote:
 [...]
Is any chance that a few years later D will adopt packed union/structured with bit fields, slicing and formatting (Erlang-like maybe) ? I see D can be intensively used in embedded and telecom application, where bit ops is definetely required.
Same
Do you have issues with the earlier alternative? https://dlang.org/phobos/std_bitmanip.html#bitfields I use and like this one quite a bit. The new bitfield variant *might* be important for C interop? I'm not in embedded development at the moment but if I went back there I'd prefer the original D bitfields for any new development.
Sorry, I meant to reply to "I see D can be intensively used in embedded and telecom application". That's what I wrote "Same" to
Oct 08 2023