Open source dmd on Reddit!

Michel Fortin michel.fortin at michelf.com
Fri Mar 6 18:34:46 PST 2009


On 2009-03-06 14:35:59 -0500, Walter Bright <newshound1 at digitalmars.com> said:

> Andrei Alexandrescu wrote:
>> "Can't live without bitfields! Give me bitfields and I'll lift the Earth!"
>> 
>> "Here they are, std.bitmanip. Well-defined and more portable and 
>> flexible than C's."
>> 
>> "Meh, don't like the definition syntax."
> 
> Classic.

Well, he certainly has a point. Compare this:

	mixin(bitfields!(
	    uint, "x",    2,
	    int,  "y",    3,
	    uint, "z",    2,
	    bool, "flag", 1));

With this:

	uint x : 2;
	int  y : 3;
	uint z : 2;
	bool flag : 1;

The second is certainly prettier and more readable.

Does it matter much? Not to me; I rarely use bit fields. If I were 
using them a lot, perhaps I'd be more concerned.

While I don't care very much about bitfields, that "mixin(tmpl!(...))" 
syntax is awful. "mixin tmpl!(...)" is better, but has too many 
limitations, and it isn't always clear for the user which one should be 
used. Couldn't D2 get a better syntax for mixins?


-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d-announce mailing list