lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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.