lua-users home
lua-l archive

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

Here is a rough proposal for a table-protection mechanism inspired in part
by the environment material in the 5.1 module system.

Add a metatable entry: __protected

If present, then all reads and writes of the table get checked and have to
be invoked from code with an environment equal to that specified by the
__protected field. If the code doesn't pass the protection test, then
__index or __newindex get invoked as appropriate. Method lookup bypasses the
__protected field.

Routines like table.insert could check their caller's environment.

Why would one want this? Primarily as a runtime check to confirm