[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: is "__metatable" an event similar to "__gc" and "__tostring" or is it a convention?
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Mon, 7 Jul 2003 11:35:46 -0300
>To support object:method() syntax, LHF adds a "metatable" key to the
>"gdbm" table in "C" and then in "gdbm.lua" he has a statement like
>this:
> gdbm.metatable.__index=gdbm
>which is what is allowing the object:method() syntax to work;
I added the "metatable" field in the "gdbm" table to be get access in Lua
to the metatable of GDBM objects in Lua. It was purely for convenience, because
some things are easier to write in Lua, specially during the test phase.
The code
gdbm.metatable.__index=gdbm
could have just as easily been written in C, as done in
http://lua-users.org/wiki/UserDataWithPointerExample
--lhf