[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Simple classes
- From: steve donovan <steve.j.donovan@...>
- Date: Wed, 1 Jun 2011 14:18:21 +0200
On Wed, Jun 1, 2011 at 12:43 PM, Jose Marin <email@example.com> 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 http://lua-users.org/wiki/SimpleLuaClasses,
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
http://stevedonovan.github.com/Penlight/#T9, which links to the
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.