On Sat, Oct 3, 2009 at 10:48 PM, Wouter Bolsterlee <[email protected]> wrote: > Op zaterdag 03-10-2009 om 22:40 uur [tijdzone +0300], schreef Xan Lopez: >> On Sat, Oct 3, 2009 at 10:24 PM, Magnus Therning <[email protected]> wrote: >> >> Objects in JavaScript are dictionaries (I mean, even the syntax is the >> >> same...), and I'm sure there's plenty of implementations of data >> >> structures >> >> like Python sets around. >> > >> > No, they are "dictionary-like", not proper dictionaries. For instance keys >> > can only be strings or numbers. >> >> So what else can be a key in Python dictionaries exactly? The >> documentation mentions a tuple of immutable objects, which I guess can >> have its uses, but saying that javascript does not have dictionaries >> (or only "dictionary-like" objects) because of this seems a bit over >> the top to be honest. > > Anything that can be hashed can be used as a dictionary key. For > objects, the key can be simply the memory address. This is very useful > for object-to-something dictionaries.
Anything that can be hashed can be used as a key in any dictionary type, that's a borderline tautology :). The point is what kind of python object can be used as a key in a python dictionary without any other intermediate step. The documentation seems to imply you can only use immutable things, which seems reasonable but is not, IMHO, so superior to the JS implementation to warrant saying that JS's are not real dictionaries. In any case this is not really very relevant, I just wanted to point out that dictionaries are a pretty core type in JS, so saying they do not exist is not true. They are not exactly like Python's? Sure. Xan > > — Wouter > _______________________________________________ epiphany-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/epiphany-list
