[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Metatables are "hard" (Re: Question about __index and classes)
- From: Dirk Laurie <dpl@...>
- Date: Mon, 29 Aug 2011 08:18:44 +0200
On Mon, Aug 29, 2011 at 06:54:48AM +0200, Josh Simmons wrote:
> __newindex is an odd wording though I'm not sure it'd be really worth
> changing at this point.
On the contrary, it is a perfect name.
It is the name of a routine that is only invoked if you assign
something to tbl[idx] when idx is not an existing index into the
table; that is to say, when idx is a new index.
Since most of the confusion arises because folk think it is invoked
for *every* assigment into a table, it is a much more suitable name
than e.g. __assign or __setindex would have been.