lua-users home
lua-l archive

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

>Is there some particular reason, why setmetatable doesn't work on userdata
>from Lua?

Safety. One of the main guidelines in the design of Lua is that it should not
be possible to crash the host program from a Lua script. (On the C side,
you're free to do as you please.) So, if you could set userdata metatables
in Lua, you could fake C objects and then crash the host program. Something
like this:
	x:read()	-- probable crash