So if C# returns 3 when I do "1+1" it is not a bug?
It's not a bug in the software if the software is specifically designed to
do that, no.
If it does the wrong thing, it is a bug.
If the software is specifically designed to do that, then it's not the
wrong thing for the software to do.
Anyway, we're kinda going around in circles.
Only because you are starting with a prejudiced view of what is a bug.
A Color structure is simply a piece of data. In this case, it happens to
represent an abstraction of something we know of in the real world. Some
such pieces of data follow the exact same rules that we follow in the real
world, but some do not. I submit to you that in this case, this data
structure does not.
Likewise, in Jon's reply to your "1+1=3" example, you are allowing your
prejudice of what that exact sequence of characters means in the real
world to affect your interpretation of what's going on in the computer.
While it's helpful for the compiler to be designed so that adding 1 to
itself results in 2, just as it does in the real world, some insane
compiler designer could in fact declare that his compiler will result in3
when that operation is performed.
He could do so for any variety of reasons, including that one or more of
those symbols don't actually mean in his compiler what they mean in the
real world, or simply that he wants to be arbitrary. But regardless, if
he writes the specification for the compiler stipulating that that's
what's supposed to happen, then if the compiler does exactly that, then
the compiler is bug-free (at least with respect to that feature).
You may rightfully say that the actual design of the compiler is flawed
(or even "buggy"). But the software itself is operating exactly as it was
designed, and thus is NOT flawed or buggy. It's not a bug for that
compiler, with that design, to make 3 the result of adding 1 and 1 (or
whatever operation might actually be represented by the sequence of
characters "1+1").
Ask 1000 C# developers what "new Color (0, 0, 0).Equals (Color.Black)"
would
return...
What it _would_ return? Only a developer who is familiar with the
structure and who knows the exact behavior of the Equals() method should
be answering that question, and they will tell you exactly what the
documentation says.
Change your question to "should return", and I'd agree that you might get
a wider variety of answers, including many (perhaps even a majority) who
agree with you on what it _should_ return.
But that wouldn't be relevant with respect to the question of whether the
structure's method has a bug in it or not. The only thing relevant there
is what Microsoft's .NET designers intended the method to do.
The MS docs say: "Tests whether the specified object is a Color structure
and is equivalent to this Color structure." Note *Equivalent*. Then
elsewhere, it says "equal" not "equivalent" - this is different.
You can nit-pick the docs all you want, the fact remains that they still
clearly state the behavior of the Equals() method.
Then the docs say: "This method compares more than the ARGB values of the
Color structures. It also does a comparison of some state flags. [...]"
So what are Color "state flags". If that is not
documented, then the docs are at best incomplete and ambiguous. Does
MSFT
define Color state flags anywhere?
They don't need to, since they aren't part of the API. That is, the
contract that the Color structure exposes to you.
I don't see how mentioning some aspect of the internal implementation of
the Color structure causes the documentation to be ambiguous.
I can more readily accept the characterization of "incomplete", but only
because it's practically impossible to provide documentation that is
"complete". In something as vast as .NET, there's always going to be
hidden corners where the documentation does not provide a literally
complete discussion of the API. But as long as these oversights don't
affect how you use the API, I consider them to be insignificant.
So, sure...the docs are incomplete, but in this case only in an
insignificant way. (There are lots of other places that the docs are
incomplete in a _significant_ way...why is this the issue you have decided
to chase down with such tenacity?)
And certainly in this case, you don't need to know what those flags are.
You don't really even need to know that they exist, though it's nice of
Microsoft to mention them so that perhaps you can at least have a little
bit more insight as to why the Color.Equals() method works the way it does.
Pete