lua-users home
lua-l archive

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


On 11 June 2011 07:26, zhiguo zhao <zhaozg@gmail.com> wrote:
> cdata create with ffi.new.
> getmetatable(cdata) return string 'ffi', why not a table
> when use ffi, we need to handle getmetatable not return table.
>

That can technically happen in plain Lua already:

    local a = setmetatable({}, { __metatable = "string" });
    print(getmetatable(a));

Although I've never seen a string used before, boolean 'false' is
often used just to hide/protect a metatable.

Regards,
Matthew