[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Simple classes
- From: Jose Marin <jose_marin2@...>
- Date: Wed, 1 Jun 2011 05:22:56 -0700 (PDT)
Thanks for the tips, guys!
--- Em qua, 1/6/11, steve donovan <firstname.lastname@example.org> escreveu:
> De: steve donovan <email@example.com>
> Assunto: Re: Simple classes
> Para: "Lua mailing list" <firstname.lastname@example.org>
> Data: Quarta-feira, 1 de Junho de 2011, 9:18
> On Wed, Jun 1, 2011 at 12:43 PM, Jose
> Marin <email@example.com>
> > 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
> 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.