DIP: add Bit Fields
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Mon Apr 22 17:28:25 UTC 2024
On 23/04/2024 4:16 AM, Walter Bright wrote:
> In the very rare case of actually needing an exact layout, with 5
> minutes of effort any layout can be duplicated with C bit fields. If
> that's too much effort, one can write explicit shift/mask code, and
> encapsulate it into a function. (Once the function is inlined, there is
> zero extra overhead for it.) Or one can use std.bitmanip to do that
> automatically.
>
> Yes, we can add extra syntax and semantics to make this controllable by
> the user, but it's so rarely needed it's over-engineering.
It depends so heavily on what you are doing, as I'm sure you know.
If you work with file formats, IPC (sockets, pipes ext.), CPU flags for
embedded devices, or performing instruction encoding for fun, you'll end
up dealing with this stuff heavily enough that you want language support.
If all you need it for is some flags in process then of course it
appears to be over-engineering.
I'm in the former group often enough that it is pretty uncomforting for
me to see that this feature won't exist in those circumstances and this
thread shows that I am not alone in this.
More information about the dip.development
mailing list