lua-objects

lua-objects is an advanced object oriented module for Lua (OOP).

This single-file module started its life as dmc-objects and was used to create mobile apps built with the Corona SDK. It was later refactored into two files lua_objects.lua & dmc_objects.lua so that pure-Lua environments could benefit, too (eg, lua-corovel).

This power-duo have been used to create relatively complex Lua mobile apps (~60k LOC), clients for websockets and the WAMP-protocol, and countless others.

Features

Some of the features not found in other Lua OOP modules:

  • new! customizable methods and names for constructor/destructor
  • new! multiple inheritance (all way to top level)
  • new! handles ambiguities of inherited attributes
  • new! advanced support for mixins
  • new! default inherited class, Class
  • getters and setters
  • correctly handles missing methods on super classes – superCall()
  • optimization (methods from super classes can be cached on class/instance)
  • common methods/properties – .is_class, .is_instance, .isa(), .supers. .class
  • structured object setup/teardown

Examples

The module has unit tests available. Also there are many modules within dmc-corona-library which use this for their functionality.

Download

github

Module Documentation

Here are the available pages of documentation to help you better understand lua-objects.

Getting Started - lua-objects

lua-objects is an advanced OOP module for Lua.