lua-users home
lua-l archive

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


Ah, this is exactly what is happening--I had forgotten about this.  In
fact, the reason why iterating over my list works while indexing into
does not is that I had written a __eq metamethod to compare the
contents.

So two questions remain:
1) Is there any way, on the userdata side, to change how it is used as
an index?
2) If I were to switch to light userdata, is there any way to guarantee
type safety (I assume no, because there is no metatable)?

Thanks again,
-W

--------------------------------------------
Date: Tue, 10 Feb 2004 14:06:03 -0500
From: scott <scott+lua@escherichia.net>
Subject: Re: Using full userdata as table index?
To: Lua list <lua@bazar2.conectiva.com.br>
Message-ID: <20040210140603.G14127@escherichia.net>
Content-Type: text/plain; charset=us-ascii


Just because your userdata object has the same value, doesn't mean that
it is the same object. AFAIK the table lookup occurs by reference, not
by value. Therefore, two different userdata objects could both be
refering to the same guid, but still be two refering to two different
lua objects. 
An example from my engine...