September 17, 2015 Re: Behavior of opEquals | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Timon Gehr | On 09/09/2015 09:20 PM, Timon Gehr wrote:
>
> On 09/09/2015 01:32 AM, Jonathan M Davis wrote: (moved from above)
>> I really don't see any reason why it would even make sense to declare
>> operators separately from a type.
>
> One reason is that single dispatch can be awkward. A textbook example
> would be: ...
I just noticed that I missed to concretely mention one obvious use case:
Overloading mutating operators on reference types with ("logical") value semantics, possibly in combination with hash consing. E.g. classObject++, or classObject+=x.
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply