lua-users home
lua-l archive

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


Nicolas Noble wrote:
> 
> How exactly does the __gc metamethod works ? It just
> seems I'm not using it the right way.
>[...]
> function createobj(n)
>     local t = {n = n}, mt
>     mt = {__gc = mygc}
>     setmetatable(t, mt)
>     return t
> end

The __gc method is only for userdata objects.  For other
types it's ignored.

Btw, "local t = {n = n}, mt" looks wrong.

Question: should Lua issue an error if there are
          more expressions than variable names?

Ciao, ET.