On 03/24/2010 08:28 AM, bearophile wrote:
Regan Heath:
I find being able to define bit flag values with an enum and
combine them using | and |= or negate with&= ~flag etc very
useful.
The cause of the problem here is that you are trying to use enums for
a different purpose, as composable flags. In C# enums and flags are
not the same thing, you can use the [Flags] attribute:
http://www.codeguru.com/vb/sample_chapter/article.php/c12963 The
ridiculous thing of D development is that no one ever takes a look at
C#, it often already contains a solution to problems we are just
starting to find in D (or often that we just refuse to see in D).
There are many good things in many languages to look at. C# has its
pluses and minuses, but is definitely not the be-all, end-all of PLs. In
particular, economy of means does not seem to be one of C#'s strengths.
As
they say: "Those who cannot learn from C# are doomed to re-invent it,
often badly."
Who are "they"?
(In D you can solve this problem creating a flags struct, using a
strategy similar to the one used by std.bitmanip.bitfields, but it
feels hackish).
Why does a mechanism that allows creating bitfields, custom enums,
flags, custom-base literals, and more, feel hackish, whereas dumping a
wheelbarrow of narrow-usefulness features with every release while still
failing to address major problems (concurrency, immutability) feels not?
Andrei