Stable D version?
Chris Cain
clcain at uncg.edu
Mon Apr 22 22:16:32 PDT 2013
On Tuesday, 23 April 2013 at 05:05:29 UTC, Chris Cain wrote:
> 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.
Actually, I'm going to strengthen this a bit more. I'd _still_
think it's a good idea to keep structs the way they are. I expect
(as I think many would) structs to be very bare metal. Very
little auto-magic should touch them because they are used so
often for low-level tasks and you really ought to be very precise
when you're defining them and their behavior. In that context,
"==" being the same as "is" makes sense from my perspective and I
wouldn't expect anything else unless I explicitly told it
otherwise.
If you want some of that type of automatic "just works" behavior,
you're probably using structs as more higher level concepts.
Maybe consider using a tuple instead?
import std.stdio, std.typecons;
void main() { writeln(tuple("a") == tuple("a".idup)); }
Outputs:
true
And it's shorter and simpler than the struct example.
More information about the Digitalmars-d
mailing list