lua-users home
lua-l archive

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

After way too much Tequila shots, here is the delusion of the premiss of my grandly named "LUObject"... :o)

A couple of arbitrary conventions:

- One class per file.
- A class is a "package" as shown in PIL, Chapter 15.2 [1].
- An object is a table of closures as shown in PIL, Chapter 16.4 [2].
- Everything is defined in terms of table of functions.

In theory, "LUObject" supports both class and instance methods, inheritance and encapsulation.

See attachments for examples:

- LUObject is the root class. It defines 3 class methods (class, new and methods) and 5 instance methods (class, equals, hashCode, this and toString) - MySubClass extends LUObject. It defines no new methods, but extends the toString instance method of its parent. - MyOtherSubClass extends MySubClass. It defines 1 new class method (doIt) and one new instance method (doItQuick) as well as extending the toString instance method of its parent.

anObject =
print( anObject.toString() )

anotherObject =
print( anotherObject.toString() )


anObject.equals( anotherObject )

Does any of this make sense? At all? Or do I need more Tequila? :P




Attachment: LUObject.lua
Description: Binary data


Attachment: MySubClass.lua
Description: Binary data


Attachment: MyOtherSubClass.lua
Description: Binary data