lua-users home
lua-l archive

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


André de Leiradella wrote:
+ Classes and objects

It's #1 to me. This seems to be a common wish, every now and then we see
threads on this topic and many people have developed workarounds so that
it looks like Lua is a real OOP language, and (or as) the game
programing community uses C++ a lot. It's not necessary to add
predefined classes to the core (like Java's VM that rely on String and
StringBuffer at least), just the ability to define classes, instantiate
objects and calling [inherited] methods.

This is very possible... there are various ways to do it, but
that's what metaprogramming is about.  Regardless of how you
get there you end up with something about as elegant as you
could ask for (obj:method(), obj.attribute), but you have to
'do it yourself' (though a simple implementation is already
very simple).  So I can't see a 'blessed' way of doing
this making it to the core, but I assume it's already well-covered
by projects such as LuaCheia (and definitely amply covered by
the Wiki code).

--Adam
--
Adam D. Moss   . ,,^^   adam@gimp.org   http://www.foxbox.org/   co:3