lua-users home
lua-l archive

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

On Wed, Jun 1, 2011 at 12:43 PM, Jose Marin <> wrote:
> I´ve found some links about OOP in Lua, but none seemed to be pratical/fast to be used in a game, also the call to the base class methods is a problem, too.

One scheme is described in,
which provides a straightforward implementation of a so-called 'fat
metatable' approach; that is, methods of objects sit in their shared
metatable, and the derived classes get a copy of the inherited methods
as well as their own.

Another write-up of a later version is found here, which links to the
following code:

Now, as for performance: this is suitable for situations where there
are a lot more objects than classes. If each object had references to
the methods, then this would not be memory-efficient; here the methods
are shared among objects.

steve d.