lua-users home
lua-l archive

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


2009/6/17  <contact@imagine-programming.com>:
>> Van: Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>
>>> > setmetatable(__tMemory).__newindex=nil
>>>
>>> wouldn't that be:
>>>
>>> getmetatable(__tMemory).__newindex=nil
>>
>> oops, you're right, sorry.
>
> Thank you for your help, another thing learnen about metatables.

With that solution, once some keys are added to the table, reseting
the __newindex to the ronly function won't be enough to make it
read-only again. __newindex is only called if the key is not in the
table.