[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Microsoft DLR and Lua?
- From: Tony Finch <dot@...>
- Date: Mon, 2 Jul 2007 10:10:31 +0100
On Sun, 1 Jul 2007, Fabio Mascarenhas wrote:
> On 7/1/07, Tony Finch <dot@dotat.at> wrote:
> >
> > Does it support arbitrary types as table indexes?
>
> Python dictionaries can have anything as a key, so I guess yes.
The Python reference manual says only immutable types can be used as keys,
which rules out using dictionaries and functions as keys. In Ruby, any
object with a hash function can be used as a key; typically if the
contents of the object change the hash value does as well - i.e. it's not
based on object identity like Lua, so if you change the contents of a
table used as a key then it will no longer index the same location. (Also
Ruby has mutable strings so they have to break this rule for string
indexes on tables. Yuck.)
Tony.
--
f.a.n.finch <dot@dotat.at> http://dotat.at/
SOUTH UTSIRE: SOUTHEAST 6 OR 7, OCCASIONALLY GALE 8, DECREASING 4 OR 5.
MODERATE OR ROUGH. SHOWERS. GOOD.