lua-users home
lua-l archive

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

On Fri, Nov 21, 2003 at 05:59:29PM -0800, Ando Sonenblick wrote:
> But then that breaks the getting/setting of values as obj.x (where x 
> doesnt initially exist as part of the userdata's metatable), which 
> normally gets instantiated in the __newindex, now is found to be the no 
> op function.

maybe i misunderstood your problem, but if you don't set the index value
in your __index metamethod but instead just return a no-op function,
shouldn't something similar to the following work ?

% lua
Lua 5.0  Copyright (C) 1994-2003 Tecgraf, PUC-Rio
> t = setmetatable({}, {__index=function() return function() end end})
> t:xxx(1)
> function t:xxx(v) print(v) end
> t:xxx(2)