string and char[]
Jesse Phillips
jessekphillips+d at gmail.com
Fri Apr 8 07:27:33 PDT 2011
On Fri, 08 Apr 2011 17:40:32 +0400, Denis Koroskin wrote:
> int compare(char[] lhs, char[] rhs) pure {
> if (lhs < rhs) return 1;
> if (lhs > rhs) return -1;
> return 0;
> }
>
> is not.
>
> For some reason (bug?), both compile with 2.052.
Purity has nothing to do with the type. "Hello" and a char[] storing
"Hello" will always produce the same results when passed to this
function. The fact that it can be changed to "Byelo" does not effect the
results for when "Hello" is passed in.
I agree that Objects make for great mutable keys, but how can you
guarantee the hash won't change when the contents change, toHash is
overridable after all.
More information about the Digitalmars-d
mailing list