Why struct opEquals must be const?

Pelle pelle.mansson at gmail.com
Mon Oct 18 11:17:37 PDT 2010


On 10/18/2010 05:55 PM, Steven Schveighoffer wrote:
> On Mon, 18 Oct 2010 11:19:54 -0400, Pelle <pelle.mansson at gmail.com> wrote:
>
>> On 10/18/2010 05:07 PM, Steven Schveighoffer wrote:
>
>>> What case were you thinking of for requiring mutablity for equality
>>> testing?
>>>
>>> -Steve
>>
>> I was thinking along the lines of not enforcing unexpected
>> restrictions on programmers because we couldn't think of a use case.
>> This isn't an enabler.
>
> But D also has a good goal of not enabling bad design. Even if through
> convention. I personally don't see how opEquals can be forced into a
> particular signature (the current rules are too strict), but a
> philosophy that opEquals should refrain from changing the objects in
> question is a good one to have.
>

I agree with this philosophy :-) I do not think it should be compiler 
enforced, however.

>> Today, the check isn't very intelligent, which makes immutable structs
>> unusable.
>
> Absolutely, hence the bug report.
>
> -Steve



More information about the Digitalmars-d mailing list