lua-users home
lua-l archive

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

On Sun, Jul 1, 2012 at 7:23 PM, Dimitris Papavasiliou <> wrote:

I'm not familiar with LuaJIT.  From what I understand these aren't
userdata values.  Are cdata new kinds of values introduced by LuaJIT?

Yes, much like userdata but created via the ffi interface rather than the C interface. 

The absolute simplest example is

>  ffi=require"ffi"
>  t=ffi.metatype("struct{int a;}",{__tostring=function(x) return "custom tostring " .. x.a end})
>  a=t(2)
>  a
>  print(a)
custom tostring 2
>  type(a)