lua-users home
lua-l archive

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

On Thu, 16 May 2013 09:27:31 +0100
Rob Kendrick <> wrote:

> On Thu, May 16, 2013 at 01:20:51PM +0530, Muqtheear S wrote:
> > Hi all,
> >         Please suggest me a *Lua OOP library* which should
> > support*Abstract classes
> > * along with some basic feature as well.
> There are plenty of OOP libraries to choose from on the same wiki
> Steve suggested to you before, go pick one you like.  If you don't
> like any of them, write your own.

Rob's not being facetious suggesting writing your own. Creating your
own tools in Lua is much easier than in other languages, thanks to
Lua's simplicity, table-centricity, functions as data (first class) and
nested functions with upvalues.

I'm not a big fan of inheritance, and therefore I'm not knowledgeable
about abstract classes, but my understanding is that if you have the
ability to do inheritance, that pretty much gives you the ability to do
abstract classes. From what I understand from the people on this list,
you do inheritance with metatables. When I make "classes" in Lua, I use
a table with a functional element called "new", that returns a data
table called "self" that contains the "object methods", while the new
function itself contains the "object properties".

The last thing I'd like to say is that Lua is different enough that
sometimes you can use an easier algorithm or architecture with Lua than
with most other languages. For my EMDL to UMENU converter, in Perl,
Python and Ruby I used pretty much standard OOP. But when I wrote the
same program in Lua, Lua's extremely powerful, versatile and efficient
tables gave me a different, and in my opinion easier, way to solve the