simple inheritance in lua

Posted by open768, Posted on July 14, 2012

GitHub URL: 
https://github.com/open768/library/blob/master/lib-class.lua

hi wrote a simple library for creating subclasses
usage below

1
2
3
4
5
6
7
8
cClass.createGroupInstance(psClassname, poSuperClass)
-- multiple inheritance.. creates a display.newGroup() that also has  the methods and properties of the superclass
 
cClass.createInstance(psClassname, poSuperClass)
-- creates an instance of the superclass
 
cClass.addParent( poObj, poParent)
-- multiple inheritance.. adds a new parent to an instance - *be careful*, methods that have previously been defined in the parent will not be overridden.

oop - no metas, no module()

Posted by jack0088, Posted on December 16, 2011, Last updated December 19, 2011

Introduction

I've build a Class - with actually just one function - for easy and very basic OOP in Lua. After some tryings I've decided to go without metatables and without module(...).
This is my own approach and of course ain't the best out there, but as far as I've tested it, it does its job very well for me, so may it do for you too.

My first approach was using metas, as everywhere suggested. And this are some illustrations of how I did that. ...I've quashed that.

classes.lua - A simple Class implementation in Lua for Object-Oriented Programming

Posted by Varen, Posted on December 4, 2011, Last updated December 6, 2011

GitHub URL: 
https://gist.github.com/1429475

What?

classes provides a simple solution to Object-Oriented Programming in Lua. It has the basic OOP features one might expect, such as inheritance, and covers up dealing with metatables and the like.

Why?

classes was developed because when I started working with Corona, I had only a basic knowledge of Lua. Working on big projects, in any language, can usually benefit from some OOP functionality. There are a few libraries out there that bring this to Lua. This is a simple, lightweight, ~100 line implementation.

How?