[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: next() and table changes
- From: "Vyacheslav Kalitkin" <vkalitkin@...>
- Date: Tue, 29 Nov 2005 13:17:25 +0300
Hello,
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
k,v=next(table,k)
if k==nil then break end
if func(k) then table[k]=func2(v) else table[k]=nil end
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