Implicit enum conversions are a stupid PITA

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Mar 25 20:07:58 PDT 2010


On 03/25/2010 09:38 PM, Nick Sabalausky wrote:
> "Andrei Alexandrescu"<SeeWebsiteForEmail at erdani.org>  wrote in message
> news:4BABC1F7.6080504 at erdani.org...
>> On 03/25/2010 02:52 PM, Nick Sabalausky wrote:
>>>
>>> I can agree mixins are a perfectly fine interim solution for anything not
>>> already in the language, and for truly obscure needs (I use them all the
>>> time for both situations myself). But I'd still hardly consider flags and
>>> bitfields (to be clear, I'm talking about the abstract concept of a
>>> bitfield
>>> in general, not necessarily the C-style
>>> struct-with-sub-byte-member-alignment bitfield syntax/semantics) to be an
>>> "obscure" need in something that's supposed to be a systems language. I
>>> guess we just have a fundamental disagreement on that.
>>
>> In what ways do you find the bitfield interface wanting?
>>
>
> Ignoring frequency-of-usage for the moment, since this is a question of
> syntax, compare these two syntaxes of creating a struct:
>
> mixin(struct!("myStruct"
>      uint, "x",
>      int, "y",
>      uint, "z",
>      bool, "flag"));
>
> Versus the current:
>
> struct myStruct {
>      uint x;
>      int y;
>      uint z;
>      bool flag;
> }
>
> There's just less syntactical noise, and the syntax is designed around the
> semantics rather than shoehorning various generic syntaxes to fit the
> purpose.

But frequency of usage is essential. This is about bitfields, not 
struct. The former are arguably much less used than the latter. And 
then, there are many more uses than definitions.

Andrei



More information about the Digitalmars-d mailing list