Operator overloading for non-value objects
zenparsing at gmail.com
Tue Jan 14 09:06:22 PST 2014
> In the worst case, when I don't know if I have a string or an URLUtils
> object, I just ensure that at least one member of the equality operator is
> stringified—and, most importantly, that it is evident from reading my code
> that one member is stringified:
> a.href == url
> String(whatever) == url
Is an equality operator which requires one to remember such details a good,
dependable equality operator? Does it really even express a meaningful
concept of "equality"?
Attaching more nuance on top of "==" via overloading seems like it will
make things worse, not better.
Brendan, can you provide a value class example which includes a
user-defined "=="? I'd like to see it in context.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss