lua-users home
lua-l archive

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


Hello Edgar,

    See below.

----- Original Message -----
From: "Edgar Toernig" <froese@gmx.de>
To: "Lua list" <lua@bazar2.conectiva.com.br>
Sent: Sunday, December 14, 2003 1:12 PM
Subject: Re: Garbage Collector


> 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?
...

    Are you asking because the mt will be a global variable, and not a
local?
    If yes, I think the best is to modify lua to allow the local keyword
work for ,XXX too. I always make this error, and always need to rewrite the
code.
    If no, someone/you show me than what you are asking ;-).

                                                    The God's Peace,


Leandro.