RE: Re: Mutable Bytes

Greg Ewing <[email protected]> Tue, 27 Jul 2004 17:19:59 +1200
Newsgroups gmane.comp.lang.prothon.user
Message-ID <[email protected]>
Mark Hahn <[email protected]>:

> I've been thinking of adding a Prothon language feature that let's you set
> the immutable bit on any individual object.  The dictionary checks that bit
> for allowing keys, not the object type.

That would be the wrong test for the dictionary to make.  The
criterion for an object being an acceptable dict key is that its
comparison and hash functions depend only on immutable state. It can
have other state that is mutable, as long as it doesn't affect
equality.

Python doesn't check the object type, by the way. It just checks
that the object has a hash function. It's up to the author of
the hash and cmp functions to ensure they behave appropriately.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
[email protected]	   +--------------------------------------+