I'll point out that part of Steven's proposed SortedDict implementation supports "Tokens", which represent the location of a (key, value) pair in a dictionary. These are generalizable to hash-based Dicts, and should make it possible to update the dictionary when a key is changed.
For hash-based dictionaries, the main concern is keeping track of the validity of tokens when the hash table is resized. Cheers, Kevin On Monday, October 13, 2014, Ivar Nesje <[email protected]> wrote: > I think the easy access to user defined immutables in Julia would make a > great argument for disallowing mutable keys. It's an unfortunate choice to > make tough, because it is a pure restriction that makes some problems > harder to solve. It also seems somewhat costly in implementation (because > we need to check a new recursive immutable property). The result will be > that lots of users gets a error about mutable keys, instead of a KeyError > only when the key changed. > > We could make a copy on insertion, but that would require us to also take > a copy before iterating on the keys as well. That would create lots of > temporary copies, that Julia currently doesn't have the infrastructure to > optimize away. > > Ivar > > kl. 19:12:37 UTC+2 mandag 13. oktober 2014 skrev Stefan Karpinski følgende: >> >> Yeah, there's no ideal solution. Python disallows mutable keys; Ruby >> allows them and has the same behavior as Julia here; Perl turns all keys >> into strings (I think that string keys may still be mutable in Perl, but >> it's become so hard to get a readline-enabled prompt in Perl, that I gave >> up on checking). >> >>> >>> >>
