lua-users home
lua-l archive

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


Is it correct to change table values in table traversing with "next()" or
"lua_next()" functions ? Keys still without changes, but nil can be assigned
to it's value inside cycle.

For example:

k=nil; v=nil
while true do
 if k==nil then break end
 if func(k) then table[k]=func2(v) else table[k]=nil end

Also, how can I use metatables for make table values "read only" (raise
error on assigments) not only for any "table.key=value", but:
1) "table.remove", "table.insert", "table.sort" and etc. must raise "read
only" error too
2) this table must worked with "next","ipairs" and etc. traversal table functions

Best regards,
Vyacheslav Kalitkin