proper bit fields in the D2 language?

Brad Roberts braddr at puremagic.com
Tue Apr 21 22:24:04 PDT 2009


nobody wrote:
> I remember read D's introduction page that C's bit field is something will be
> dropped from D.
> 
> But now I see dmd/src/phobos/std/bitmanip.d line 30 ~ 98: bit field functions
> are generated at compile time,
> 
> private template createAccessors(...) {
>   // getter
>   // setter
>   ...
> }
> 
> I wonder how efficient is this. If we are going to have bit fields in the
> *std* library, why not support it properly in the language. I think the
> compiler can generate much better code than these compile-time generated
> functions, which looks like a hack to me.
> 
> comments?

The auto-generated code from the library is the same code the compiler
would end up generating.  You can test that theory by comparing the
produced assembly for a C vs a D implementation.

Later,
Brad



More information about the Digitalmars-d mailing list