Stable D version?

deadalnix deadalnix at gmail.com
Mon Apr 22 23:34:56 PDT 2013


On Tuesday, 23 April 2013 at 05:05:29 UTC, Chris Cain wrote:
> On Tuesday, 23 April 2013 at 04:58:30 UTC, anonymous wrote:
>> For fast bitwise comparison there's the "is" operator.
>> The "==" operator should be "slow".
>> See also http://d.puremagic.com/issues/show_bug.cgi?id=3789
>
> Well okay. The docs will have to be updated for this issue if 
> it's "fixed".
>
> For instance:
> http://dlang.org/ctod.html#structcmp
>
> In any case, I stand by that if you have a particular 
> definition of behavior, you should provide it instead of 
> expecting it to "just work." But I suppose using "is" is more 
> appropriate for this type of behavior. But calling it "broken" 
> is a bit too strong.

OK let me sum this up, as you seem confused.

Whatever you think == should do, it is broken. If we assume that 
== should check for equality, then :
pragma(msg, S("a") == S("a".idup));
writeln(S("a") == S("a".idup));
writeln(S(+0.0) == S(-0.0));

Should all evaluate to true.

If == stand for identity, then they must all be false.

You see that whatever is the semantic of ==, it is not properly 
implemented right now.

Now, as we use == for equality and "is" for identity in other 
places (slices and objects for instance) it make sense to use the 
same for struct. But that another topic, as the demonstrated 
behavior is wrong, whatever is the semantic of ==.


More information about the Digitalmars-d mailing list