third draft: add bitfields to D

Daniel N no at public.email
Fri Jul 5 07:22:10 UTC 2024


On Thursday, 4 July 2024 at 18:34:00 UTC, Steven Schveighoffer 
wrote:
>
> This is a great idea. And then you can extract this as a type 
> as well!
>
> I see potential for some nice things here. For instance VRP:
>
> ```d
> uint:4 value(){
>    // return 200; // error
>    return 7; // ok
> }
>
> int[16] arr;
> arr[value()] == 5; // VRP makes this valid
> ```
>
> Walter, is this possible to do? This would make a lot of the 
> traits parts unnecessary -- you could introspect the bits just 
> from the type. e.g.
>
> ```d
> enum bitsForType(T : V:N, V, size_t N) = N;
> ```
>
> -Steve

Fits nicely with C23 _BitInt.
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2709.pdf


More information about the dip.development mailing list