Bitfield structs and suggestion

Martin d Anjou point14 at magma.ca
Tue Nov 27 18:04:40 PST 2007


> Nick B wrote:
>>  [...]
>>  As no one else if volunteering at present,
>>  I would like to suggest the following.
>>
>>  You create one document that covers the following:
>>
>>  1. Detail exactly the Bitfield functionality what you require (you
>>     seem to know this better than anyone on this list);
>>  2. Address why the language _needs_  this functionality;   2. Describe the
>>  target audience of the said feature(s);
>>  3. Make a pitch as to the _number_ of additional users/projects who
>>     might join the "D" community as a result of said features.
>>  [...]

I'm interested in this too.

// Pseudo-code D-like, do not try this at home
bitvector!(13) bv;
bv[3] = 1;
assert(bv == 0b0000000001000); 
bv[10:8] = 3;
assert(bv == 0b0011100001000);
alias bv[6:4] bv.field1;
bv.field1 = 2;
assert(bv == 0b0011100101000);
assert(bv && true);
bv = 0;
assert(bv && false);
bv++;
assert(bv == 1);
bv = 0b1111111111111;
bv++;
assert(bv == 0);

bitvector!(122031) bv2; // Should also work. Limit is memory.

Martin



More information about the Digitalmars-d mailing list