From: <ir...@ms...> - 2002-09-13 16:57:21
|
On Fri, Sep 13, 2002 at 05:42:53PM +0200, Stefan Schmiedl wrote: > Mike Orr (2002-09-13 08:21): > > > On Fri, Sep 13, 2002 at 01:18:21AM -0700, Brian Quinlan wrote: > > > > In some ways, YAML is a superset of Perl data structures. Most notably > > > > in regard to structured hash keys. Perl 5 doesn't have them; every key > > > > is a string. Python supports them in part with tuples, Ruby supports > > > > just about anything including objects. Perl 6 will probably follow > > > > suite. > > > > > > A minor correction: Python does allow objects as hash (dictionary) keys. > > > > ... as long as they are immutable types (i.e., can't be modified in place, > > which would change their hash position). > > Out of curiosity: Are they disallowed or just not useful? Disallowed. The hash key is supposed to be related to the value, and if the hash key changes the object will be in a different dictionary "bucket" so it won't be found. However, it can't prevent the de facto mutability of user-defined objects since instances each have a hidden dictionary for the attributes, and dictionaries are mutable. So it's up to the programmer to define "immutability". "All animals are equal, but some are more equal than others." -- -Mike (Iron) Orr, ir...@ms... (if mail problems: ms...@oz...) http://iron.cx/ English * Esperanto * Russkiy * Deutsch * Espan~ol |