My thoughts & experiences with D so far, as a novice D coder

deadalnix deadalnix at gmail.com
Wed Mar 27 10:48:25 PDT 2013


On Wednesday, 27 March 2013 at 17:36:46 UTC, Steven Schveighoffer 
wrote:
> On Wed, 27 Mar 2013 13:32:06 -0400, deadalnix 
> <deadalnix at gmail.com> wrote:
>
>> On Wednesday, 27 March 2013 at 16:52:27 UTC, Nick Sabalausky 
>> wrote:
>>> Honestly, I hate that, too. The problem is that enum is 
>>> (unfortunately)
>>> intended to do double-duty as a bitfield so you can do 
>>> something like
>>> this:
>>>
>>> enum Options
>>> {
>>>    FeatureA = 0b0000_0001;
>>>    FeatureB = 0b0000_0010;
>>>    FeatureC = 0b0000_0100;
>>>    FeatureD = 0b0000_1000;
>>>    // etc...
>>> }
>>>
>>> // Use features A and C
>>> auto myOptions = Options.FeatureA | Options.FeatureC;
>>>
>>> That possibility means that D *can't* check for validity as 
>>> you suggest.
>>>
>>
>> It can. myOptions is an int here, as Options would decay to 
>> its base type.
>
> No, it's not.  try it.  I thought as you did too until recently.
>

I knew the bug existed, but I thought it would be solved now. If 
it is how the spec specify it, then it is a spec bug and a 
compiler bug.


More information about the Digitalmars-d mailing list