On Sunday, 7 October 2012 at 09:48:50 UTC, Era Scarecrow wrote:
On Sunday, 7 October 2012 at 09:22:17 UTC, Denis Shelomovskij wrote:
I'd like to see enum syntax for flug enum. So I dislike function calls like `set_flag`, `checkAll`, etc. (IMHO)

You mean... binary basic syntax? That shouldn't be too hard. So something like..?

 Flags x;
 with(Flags) {
  x += one; //setflag
  x -= two; //clearflag
  x ^= four;//flipflag
x += [one,two]; //set flags multiple, same with flipping and clearing
  x -= [one,two];
  x ^= [one,two];


I've added binary functionality. Looking at these notes I see I forgot the enum/array part; And checking for binary true isn't added yet. However I'll get to it sooner or later. Both opBinary and opOpBinary are supported so far.

  x += one; //setflag
  x -= two; //clearflag
  x ^= four;//flipflag
    x &= two; //keeponly
    x |= two; //setFlag, same as +=

//should work fine, as with all operations, const/immutable safe.
    Flags y = x + one;

 if (x){} //compile error, will fix later
if (x != Flags()){} //should work, compare against .init (probably 0)
 if (x.state){}      //works but you shouldn't depend on this

Reply via email to