lua-users home
lua-l archive

__newindex rawsetless semantics?

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


Hi,
I guess you can claim this is a proposal but I also want feedback on it...
The idea is new semantics for __newindex so you can use it without rawset():
function __newindex(t,k,v)
 if condition then
 return k,nv
 elseif othercondition then
 return nk,v
 elseif anothercondition then
 return nk,nv
 else
 return k,v
 end
end
Unless your __newindex returns junk, this shouldn't break anything.
Thanks.

AltStyle によって変換されたページ (->オリジナル) /