[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Userdata with methods *and* table access.
- From: Dimitris Papavasiliou <jimmyp@...>
- Date: Thu, 14 Oct 2004 19:20:48 +0300
On Thursday 14 October 2004 02:40, Tom Spilman wrote:
> You seem to suggest that the order which you register functions in the
> userdata's metatable matters. From my quick test adding the "__index"
> metamethod last it does not seem to be the case.
Yes __index won't matter in that context but if you first set __newindex and
then try to set the key move to a function so that you can do foo.move(1,2)
for a table named foo, then this function won't actually be set and your code
will be run instead. Unless your __newindex code takes care of that,
foo.move(1,2) won't work.
I have repeatedly suggested to remove this complexity from lua by making
__index and __newindex be called always, independently of whether the
specified key has a nil value. This is what everyone would expect to happen
anyway. I'm bored of posting about this and, obviously, so is the list since
no one answered to a recent suggestion having to do with that (and other
matters, see post: "Unified tables and userdata").
Dimitris