lua-users home
lua-l archive

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

Michael T. Richter wrote:
There is an obvious solution to this: wrap the metamethod inside the interpreter. The metamethod returns as many values as it likes -- one to one hundred -- and the engine calling the metamethod tacks on a "userdata" to the beginning of it. Problem solved.

I'm always a fan of enforcing polite coding behaviour in the language.  ;)

This is great for many uses, but totally kills the utility of the function for proxy objects.

What if my userdata is a proxy for an external vector, and therefore wants to present itself to Lua code as a table? With a simple __typeof metamethod, it can simply return "table". With your proposed "forced politeness", it's back to patching out idiot proofing before someone who understands and accepts the consequences of their actions can use Lua to it's full.