Re: Re: Mutable Bytes
Martin Christensen <[email protected]> Tue, 27 Jul 2004 11:38:44 +0200
| Newsgroups | gmane.comp.lang.prothon.user |
|---|---|
| Message-ID | <[email protected]> |
>>>>> "Mark" == Mark Hahn <[email protected]> writes: Mark> This will have the disadvantage that Prothon keys must be Mark> totally immutable. Do you think this will be a problem? I agree with Greg that only the key should be required to be immutable. Conceptually, the reason why we want immutable dictionary keys is, after all, that we can input some known label, e.g. a string, number or whatever, and retrieve the information that we stored using that label. It would be very much counter-intuitive if the label were to change behind our backs. This is because we tend to think of strings and numbers by their values, not as objects. However, for more complex keys, I think that the identity of the object is more important, i.e. a house object will still be the same house to me if we move around the furniture a bit or give the porch a new coat of paint. Perhaps a bit too simply put, if an object contains more complex data than I can remember and type in fairly easily, I'll want that object's ID (or similar) to be used as a hash key, not its data. I'm all for letting strings be 'mutable until hashed' (put that in your bon and smoke it! :-)), and setImmutable() sounds like a good idea. However, as far as dictionary keys are concerned, I think that immutability is required for an object's dictionary key, the function that returns it should call setImmutable() itself. Does this make sense? Martin -- Homepage: http://www.cs.auc.dk/~factotum/ GPG public key: http://www.cs.auc.dk/~factotum/gpgkey.txt
signature.asc
(application/pgp-signature, 196 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iEYEABECAAYFAkEGIqgACgkQYu1fMmOQldW0mQCfeguG/JYT1Nf6rEUNoOcPQdWX tt8AnRFdG/3gsRdIR4JjJ6LsUtYn3KM2 =V5Ys -----END PGP SIGNATURE-----