third draft: add bitfields to D

Quirin Schroll qs.il.paperinik at gmail.com
Thu Jul 18 00:02:15 UTC 2024


On Wednesday, 17 July 2024 at 03:24:28 UTC, Walter Bright wrote:
> On 7/4/2024 11:34 AM, Steven Schveighoffer wrote:
>> Walter, is this possible to do?
> D originally had the "bit" data type, which represented a 
> single bit.

I would honestly love a `bit` type. Make today’s `bool` the bit 
type and re-introduce real booleans that interact with integer 
types similar to how pointer types do: You can cast pointers to 
integers and vice versa, but not implicitly. Conceptually, a 
`bit` is a number that’s 0 or 1. It’s e.g. ideal to represent 
numerical carry. `bool` could be an enum type with backing of a 
`bit`.

The wrong turn on the original `bit` type probably was the idea 
to be able to point to individual bits.


More information about the dip.development mailing list