lua-users home
lua-l archive

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


I've noticed, it doesn't make it read only again.
Would I have to first set the metatable, and then only change
the index every time? from nil to ronly() ?

--------------------------------------------------
From: "Jerome Vuarand" <jerome.vuarand@gmail.com>
Sent: Wednesday, June 17, 2009 6:10 PM
To: "Lua list" <lua@bazar2.conectiva.com.br>
Subject: Re: Read only tables.

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.

__________ NOD32 4162 (20090617) Informatie __________

Dit bericht is gecontroleerd door het NOD32 Antivirus Systeem.
http://www.nod32.nl