third draft: add bitfields to D

Dom DiSc dominikus at scherkl.de
Sun Jul 21 20:56:00 UTC 2024


On Sunday, 21 July 2024 at 16:19:04 UTC, IchorDev wrote:
> Multi-bit alignment (e.g. 8-bit) is a means of simplifying and 
> therefore speeding up the CPU architecture. Having 3 lines for 
> individual bits would be a huge waste of electricity. As it is, 
> I think being able to address individual bytes is a bit 
> antiquated, especially with new CPUs heavily favouring 
> pointer-size alignment.

Vice Versa. The address space of 64bit is so huge, having extra 
lines for all the unused high bits is a waste of electricity. 
Using them to address individual bits enables us to write 
consistent, less complex code, e.g. no invalid patterns for basic 
types with gaps (e.g. boolean). And this code need not be slower 
- alignment and shifting can be optimized away in the background 
/ hardware, the compiler can arrange variables to minimize gaps 
and speed up access by aligning.


More information about the dip.development mailing list