lua-users home
lua-l archive

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


I have user data objects with metatables that implement __index and __newindex

from a lua coder's pov, the user data is an OOP object.  they can:

obj:Call() to call a method
obj.x = 4 to get/set values

what I'd REALLY like to do is allow a method call on a non existent method to be a no op



would do nothing and lua execution would continue. Currently lua stops and says "attempt to call nil method (BadCall)"

I know that BadCall invokes __index to find BadCall and that I could instead of returning nil, return a function that does noting (acting as a no op).

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.

Not quite what I wanted!

can anyone think of how to accomplish this?

Thanks as be the norm!


Ando Sonenblick
SpriTec Software