lua-users home
lua-l archive

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


Lisa Parratt wrote:
CHU Run-min wrote:

Just now, I found table does't have the __gc event, only userdata has.
But I don't know why.


It's so those that don't understand the consequences of the garbage collector don't get their fingers burnt, at the expense of usability for those who do.

You could always patch the Lua source so __gc does get called for tables - that's what I did.


But what resource could you possibly be getting rid of? Do you have some lightuserdatas in the table that have some data? If so, then you should make these full userdatas and attach __gc methods to them. I can't imagine a case where a table needs an __gc method?

--
chris marrin              ,""$, "As a general rule,don't solve puzzles
chris@marrin.com        b`    $  that open portals to Hell" ,,.
        ,.`           ,b`    ,`                            , 1$'
     ,|`             mP    ,`                              :$$'     ,mm
   ,b"              b"   ,`            ,mm      m$$    ,m         ,`P$$
  m$`             ,b`  .` ,mm        ,'|$P   ,|"1$`  ,b$P       ,`  :$1
 b$`             ,$: :,`` |$$      ,`   $$` ,|` ,$$,,`"$$     .`    :$|
b$|            _m$`,:`    :$1   ,`     ,$Pm|`    `    :$$,..;"'     |$:
P$b,      _;b$$b$1"       |$$ ,`      ,$$"             ``'          $$
 ```"```'"    `"`         `""`        ""`                          ,P`