lua-users home
lua-l archive

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


Thanks for the tips, guys!

--- Em qua, 1/6/11, steve donovan <steve.j.donovan@gmail.com> escreveu:

> De: steve donovan <steve.j.donovan@gmail.com>
> Assunto: Re: Simple classes
> Para: "Lua mailing list" <lua-l@lists.lua.org>
> Data: Quarta-feira, 1 de Junho de 2011, 9:18
> On Wed, Jun 1, 2011 at 12:43 PM, Jose
> Marin <jose_marin2@yahoo.com.br>
> 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
> following code:
> 
> https://github.com/stevedonovan/Penlight/blob/master/lua/pl/class.lua
> 
> 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.
> 
>