[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.2.0 (beta-rc1) now available
- From: Jose Luis Hidalgo <joseluis.hidalgo@...>
- Date: Wed, 15 Jun 2011 23:57:14 +0200
I use that for a library called Simple Lua Binder which wrapps C++
objects to lua. To support something like:
object:method(...)
object.method(object,...)
ObjectClass.method(object, ...)
I use the same metatable for both instances, and the table that
contains the "class Info", that's why I have __gc for both tables and
objects. In the previous release of lua 5.2 (alpha) tables didn't get
called on __gc, only objects, so I used that to know when an object is
no longer used in the luaState. Right now, I have an if to check if
the __gc gets called with an object, or a table (lua 5.2 beta)
But it's just a curiosity, it didn't affect too much.
The change from environments to no environments was much more worse,
but that was a long time ago.
On Wed, Jun 15, 2011 at 11:46 PM, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
>> 2) the last update 5.2-beta introduce a funny behavior with __gc. Now
>> you need to setup a metatable with the __gc entry before the metatable
>> is used with an user_data (or it won't be called).
>
> Yes, but you only need to set the index not the value. In other words,
> you're free to set __gc=true and set the actual metamethod later.
>
>> And also now __gc is called for tables, which didn't happen before
>> (in my code I always try to pick a user data as first argument, and
>> suddenly a table appear where user_data used to be)
>
> Only if you do set __gc for tables of course.
>
>
--
Jose L. Hidalgo Valiño (PpluX)
---- http://www.pplux.com ----
- References:
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, Frank Meier-Dörnberg
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, David Kastrup
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, Frank Meier-Dörnberg
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, Eduardo Ochs
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, Frank Meier-Dörnberg
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, David Given
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, Javier Guerra Giraldez
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, Jose Luis Hidalgo
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, Luiz Henrique de Figueiredo
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, Jose Luis Hidalgo
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, Luiz Henrique de Figueiredo