[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: userdata setmetatable
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Mon, 28 Jun 2004 08:54:46 -0300
>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=md5.new()
setmetatable(x,getmetatable(io.stdin))
x:read() -- probable crash
--lhf