This story is rated PG. Parental guidance suggested. Some material may not be suitable for children.
In her seminal novel Story of O, Pauline Réage graphically describes the main tenet of Object Oriented Programming: bondage.
While some will view this as an exemplification of OOP’s intrinsic sadomasochism, an alternative point of view would be to regard OOP as a narrative of sort, using a small, controlled vocabulary: class, object, instance, method, etc…
While not object oriented per se, Lua can be viewed as a canvas on which to craft such a system.
Lua doesn’t give you objects, but embodies you with a rather God like power instead: the power to name things.
With the power of the Word alone, one can build a fully functional, post-structuralist, object oriented system in Lua simply by naming it so.
Here is an abridged version of Lua’s Story of O:
On the First Day, there was thisClass:
local thisClass, superClass = Object.extend( Object )
On the Second Day, came the new instance:
thisClass.new = function()
local this, super = superClass.extend( superClass.new() )
end
On the Third Day, came the method:
this.dwim = function()
return true
end
On the Fourth Day, through the sheer power of the Word alone, the object came into being:
MyClass = thisClass
The rest of the week was proclaimed an extended weekend and there was much rejoicing through the land.
Or so the story goes…
Peep at the code for the intimate details of a diminutive object oriented system known as LU.
LU.tar.gz (4 KB)
* * *
In python, if you have class B that inherits from the class A, with B overriding a method of A, you can still call the method of A.
I am under the impression that with lua, the original method of A is completely lost.
— Philippe Fremy Feb 1, 04:58 PM #
supermethod:— PA Feb 1, 05:12 PM #
— Jens Alfke Jan 14, 08:43 PM #