"is" operator for structures?
Steven Schveighoffer
schveiguy at yahoo.com
Wed May 9 09:13:26 PDT 2012
On Wed, 09 May 2012 10:13:01 -0400, bearophile <bearophileHUGS at lycos.com>
wrote:
> Gor Gyolchanyan:
>
>> Because the opBinary [...]
>
> Thank for your answer, but I don't carte of "why" the D compiler accepts
> that. I only care about the D compiler statically refusing that.
This also works too:
int opBinary(string s: "booya!")(...)
or this too:
int opBinry(string s: "+")(...)
opBinary is a valid symbol, and as a valid symbol, it is a valid function,
no matter whether the compiler calls it in a special way.
I don't think it is a terrible thing, and I think statically disallowing
that would be a worse idea.
And to answer the OP, 'is' is special, it signals a bitwise compare, no
matter what the contents of the type being compared.
That being said, I understand why you want to do that. I don't see any
way around it.
-Steve
More information about the Digitalmars-d
mailing list