November 25, 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.
> [...]

Before anyone spends too much time on this, it might be worth relating a tidbit that a little bird told me (yes, it happened just like a Disney movie): an imminent release of D is going to contain bitfield support (though not necessarily looking like any of the suggestions / implementations proposed here).

Dave


P.S.  If you plan to use little birds as target practice for your .22, may I suggest you wait to see if the bird has anything to say, first?
November 28, 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
November 28, 2007
Wolfgang Draxinger wrote:
> Now with SDL I've encountered a problem: SDL makes use of serval
> bitfields and I've no idea, how to interface them to D.
> 
> Has somebody an idea how I best interface with it elegantly?

Yes,

http://www.digitalmars.com/d/phobos/std_bitmanip.html
November 29, 2007
On Nov 23, 2007 5:50 PM, Janice Caron <caron800@googlemail.com> wrote:
> I think the way to do it to have the compiler automagically write getter and setter functions for you. That way, the following would be allowed:
>
>     n = s.a; // read a bitfield
>     s.a = n; // write a bitfield
>
> but things like s.a+=, &s.a, passing bitfields by reference, and so on, would still be disallowed. That would force the programmer to do all the calculations in "real" ints, using the bitfields only for storage.

Hey, someone's been listening to me! :-)

Check out std.bitmanip in D2.008.

We have bitfields.
November 29, 2007
Janice Caron, el 29 de noviembre a las 08:45 me escribiste:
> On Nov 23, 2007 5:50 PM, Janice Caron <caron800@googlemail.com> wrote:
> > I think the way to do it to have the compiler automagically write getter and setter functions for you. That way, the following would be allowed:
> >
> >     n = s.a; // read a bitfield
> >     s.a = n; // write a bitfield
> >
> > but things like s.a+=, &s.a, passing bitfields by reference, and so on, would still be disallowed. That would force the programmer to do all the calculations in "real" ints, using the bitfields only for storage.
> 
> Hey, someone's been listening to me! :-)
> 
> Check out std.bitmanip in D2.008.
> 
> We have bitfields.

*Ugly* bitfields, but bitfield at last (language support would be much
nicer... :S)

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
Charles Chaplin once won 3rd price in a Charles Chaplin look-a-like contest
November 29, 2007
"Walter Bright" <newshound1@digitalmars.com> wrote in message news:fiksel$28qu$2@digitalmars.com...
> Wolfgang Draxinger wrote:
>> Now with SDL I've encountered a problem: SDL makes use of serval
>> bitfields and I've no idea, how to interface them to D.
>>
>> Has somebody an idea how I best interface with it elegantly?
>
> Yes,
>
> http://www.digitalmars.com/d/phobos/std_bitmanip.html

D has bit fields!  Sweet! 

December 04, 2007
Richard Bradley wrote:
>> It's not a priority, it's something that could be added later without breaking anything -- just syntactic sugar, really. We can try again later <g>.
> 
> Curious, Has there been any movement on this issue? Is there a less error-prone way to do this other then manual shifts and masks?
> 
> I am looking to write an open-source generic library for hardware design, I thought D would make a much better base then C++. I'm a big fan of what I've seen so far. Sorry to say, but D can't be a serious low-level contender without bitfield support.
> 
> I'm not talking about using it once or twice in a project, but thousands of structures for each project, and each structure having dozens of bitfields. Having to do masks and shifts just seems like a nightmare of bad code. 
> 
> I can't imagine my friends on the firmware side (or any low-level developer) wouldn't agree. 
> 
> Miles' idea of making D somehow order aware would be a huge win for this close-to-the-hardware stuff. Or even non-order aware bitfields at least isn't worse then what's allready out there.
> 
> Comments, ideas welcome.
> Richard
> 
> 
Richard

Does this help at all ?


http://www.digitalmars.com/d/phobos/std_bitmanip.html

Nick B
1 2 3 4
Next ›   Last »