Object.opEquals, opCmp, toHash
Don Clugston
dac at nospam.com
Thu Feb 16 01:47:49 PST 2012
On 16/02/12 09:35, Walter Bright wrote:
> These all need to be:
>
> const pure nothrow @safe
>
> Unless this is done, the utility of const, pure, nothrow and @safe is
> rather crippled.
>
> Any reason why they shouldn't be?
>
> 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.).
And if memoization has problems with these functions being const, it
will have problems elsewhere.
They should be const, nothrow, @safe.
I'm less sure about pure, though. What if (for example) you have a
struct which is just an index into a global table? Like a Windows
handle, for example. That should still work.
More information about the Digitalmars-d
mailing list