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];

//append ~ seemingly would be unused, or equal to +

  x = one; //reset completely to flag 'one'
  assert(x[one]);  //checking, feels like an AA
  assert(!x[two]);
  x[two] = true; //optionally secondary way to set flag
  assert(x[one, two]); //only true if both are set.

  Flags y, z;

  z = x & y; //keep only flags within y
  z = x | y; //copy flags of both x & y
  z = x ^ y; //flip flags in x from y
 }

This wouldn't be hard to add, but I was going for basic functionality, the extras are easy to use/add afterwards :)

Probably for individual flags I'd use a template so when you optimize it will give you the smallest executing size for your results. Hmmm...

The else is the only one I'm seeing a problem implementing easily, although using the built in types you can do it yourself. I'm not going to add odd binary operators if it doesn't make sense (Like shifting appending or slicing).

Reply via email to