[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: user data
- From: "Thijs Schreijer" <thijs@...>
- Date: Sat, 1 Dec 2012 13:32:09 +0100
> -----Original Message-----
> From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On
> Behalf Of Philipp Kraus
> Sent: zaterdag 1 december 2012 12:47
> To: Lua list mailing
> Subject: user data
>
> Hello,
>
> I have found in the C reference of Lua the functions lua_islightuserdata
> lua_isuserdata
>
> What is the "user data" ? Eg I have got a Lua function that returns
something,
> which datatype should I return, so one of these function will be true.
> How can I handle "user data" in C ?
Userdata is a c-side type (cannot be created in Lua, only passed to it). It
allows to represent an arbitrary chunk of memory in lua and pass it around
as a lua value. By attaching a metatable you can provide lua with a simple
means to perform actions on it. (btw; light user data is just a pointer, but
is important on equality)
Check out the relevant part in PiL http://www.lua.org/pil/28.html