Introduction

Lua is not an object-oriented language, in the sense that the language itself does not have the concept of object, in the same way it does not have arrays. However, we can use tables to create sequences and objects. Tables allow us to create sequences in different ways. For example, we can create sequences starting at index 1 or 0 --- although starting at index 1 is much more usual and is supported by syntatic sugar.

The same goes for objects that can be represented in different ways in Lua, which we call OOP models. Some models are more usual than others and are also supported by syntatic sugar. All LOOP modules assume a common basic OOP model that is very usual in Lua and is known to work well in many scenarios. However, each module extends this basic OOP model to include new features, like support for inheritance or access control. Choosing the ideal LOOP module will depend on the OOP features your code requires.

Usually, it is not a good idea to use LOOP if you do not know Lua very well. Therefore, the ideal is that you take some time to actually study Lua prior to learn and use LOOP. An excellent starting point is the Programming in Lua book.

Similarly, you generally should not use LOOP just to emulate in Lua solutions that are particularly suitable for object-oriented languages. This is because Lua provides mechanisms more powerful and flexible than classes or other popular OO concepts (check out the examples in the book mentioned above). Therefore, it is wise to first learn the language and then keep OO techniques as one of many useful resources to use in your code. Once you feel comfortable with Lua's features (you do not need to become an expert), you shall learn and use LOOP.

You may also change or extend LOOP modules to suit different situations, or evaluate and compare them to other or your own class models. Most implementations of LOOP models are quite simple and minimalist, therefore they are easy to read and understand.

On the other hand, if you do not have the time now to learn Lua, but want to find out whether you can do OOP in Lua, then take a quick look on the rest of this User Manual. However, keep in mind that LOOP models are just one possibility of OOP in Lua and it is generally possible to emulate OOP models of other languages in Lua, as done elsewhere.

Copyright (C) 2004-2018 Renato Maia

This project was originally developed in Tecgraf at PUC-Rio.