www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - More for bitfields

reply bearophile <bearophileHUGS lycos.com> writes:
This blog post shows possible ideas to make std.bitmanip.bitfields more
complete:
http://potential-lang.org/2010/07/02/quasi-quoting-ascii-art-to-define-data-structures/

An example of the ideas:
struct IntDesc_t {
  ...
  immutable IST : 3 = 0;
  immutable Unused0 : 5 = 0;
  immutable type : 4 = 0b1110;
  immutable Unused1 : 1 = 0b0;
  dpl : 2;
  p : 1;
...

That means allowing the fields to have an optional initialization value. And
they can be flagged to be immutable too :-) Bit fields that can't change are
common.

Bye,
bearophile
Jul 04 2010
next sibling parent Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
On 07/04/2010 07:20 AM, bearophile wrote:
 This blog post shows possible ideas to make std.bitmanip.bitfields more
complete:
 http://potential-lang.org/2010/07/02/quasi-quoting-ascii-art-to-define-data-structures/

 An example of the ideas:
 struct IntDesc_t {
    ...
    immutable IST : 3 = 0;
    immutable Unused0 : 5 = 0;
    immutable type : 4 = 0b1110;
    immutable Unused1 : 1 = 0b0;
    dpl : 2;
    p : 1;
 ...

 That means allowing the fields to have an optional initialization value. And
they can be flagged to be immutable too :-) Bit fields that can't change are
common.

 Bye,
 bearophile

How is this different from erlang's bitfields, aside from the mutable/immutable part?
Jul 04 2010
prev sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
bearophile wrote:
 This blog post shows possible ideas to make std.bitmanip.bitfields more
complete:
 http://potential-lang.org/2010/07/02/quasi-quoting-ascii-art-to-define-data-structures/
 
 An example of the ideas:
 struct IntDesc_t {
   ...
   immutable IST : 3 = 0;
   immutable Unused0 : 5 = 0;
   immutable type : 4 = 0b1110;
   immutable Unused1 : 1 = 0b0;
   dpl : 2;
   p : 1;
 ....
 
 That means allowing the fields to have an optional initialization value. And
they can be flagged to be immutable too :-) Bit fields that can't change are
common.
 
 Bye,
 bearophile

Sounds good. Did you have a chance to enter that into bugzilla? Andrei
Jul 04 2010
parent bearophile <bearophileHUGS lycos.com> writes:
Andrei Alexandrescu:
 Sounds good. Did you have a chance to enter that into bugzilla?

Done: http://d.puremagic.com/issues/show_bug.cgi?id=4425 Bye, bearophile
Jul 04 2010