opEquals(const ref yadaYada)

dsimcha dsimcha at yahoo.com
Mon Dec 14 07:01:47 PST 2009


== Quote from lws (invalid at email.com)'s article
> I don't know if I believe this is necesarrily bad.  It's revealing some
> bad coding on your part.
> You shouldn't be doing opEquals with an rvalue of a class.   Make
> getFoo return a reference.
> ref Foo getFoo() {} fixes the problem and avoids value-copying for no
> reason to an rvalue that's going to get garbage collected.

1.  This was in DFL's code, not stuff I wrote.
2.  It was a small struct that was cheap to copy, not a class.
3.  At any rate, the inconsistency with builtins is inexcusable.




More information about the Digitalmars-d mailing list