Object.opEquals, opCmp, toHash

Walter Bright newshound2 at digitalmars.com
Thu Feb 16 12:38:18 PST 2012


On 2/16/2012 7:52 AM, Timon Gehr wrote:
> So imo, making opEquals, opCmp, toHash const pure nothrow @safe is blocked by
> properly annotating Phobos as well as the following issues:
>
> Bugs in existing attribute inference:
> http://d.puremagic.com/issues/show_bug.cgi?id=7205
> http://d.puremagic.com/issues/show_bug.cgi?id=7511
>
> Enhancement required for making templates const correct:
> http://d.puremagic.com/issues/show_bug.cgi?id=7521

Yes, I want to get all that fixed.

>> One reason is memoization, aka lazy initialization, aka logical const. I
>> don't believe these are worth it. If you must do it inside those
>> functions (and functions that override them), you're on your own to make
>> it work right (use unsafe casts, etc.).
>
> It would be helpful if we could add cast(pure) for that purpose. The
> documentation could state that cast(pure) is only valid if the behaviour of the
> enclosing function still appears to be pure.

cast(pure) sounds like a good idea.


More information about the Digitalmars-d mailing list