third draft: add bitfields to D
Nick Treleaven
nick at geany.org
Fri Jul 5 10:19:56 UTC 2024
On Thursday, 4 July 2024 at 18:34:00 UTC, Steven Schveighoffer
wrote:
> On Wednesday, 3 July 2024 at 19:02:59 UTC, Dave P. wrote:
>> ```
>> struct Foo {
>> uint:4 x;
>> uint:5 y;
>> }
>> ```
>
> This is a great idea. And then you can extract this as a type
> as well!
A weird restricted type. Didn't dmd used to have a `bit` type
that was abandoned?
> 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
> ```
Did you mean `= 5`? If so the assignment already compiles, so VRP
would make no difference for that code.
More information about the dip.development
mailing list