Object.opEquals, opCmp, toHash
bearophileHUGS at lycos.com
Thu Feb 16 05:05:50 PST 2012
> But if the method is pure, the compiler can automatically implement this as an optimisation.
Functions like toHash take nothing and return a single size_t (hash_t). Often you want to compute the hash value lazily, but this is not possible if toHash needs to be pure. A explicit optional @memoize annotation (similar to the std.functional.memoize) allows toHash to be both catching and safe. (I was also thinking about the idea of a @trusted_pure, but I don't like it, and I think it causes chaos).
More information about the Digitalmars-d