[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Story of O
- From: PA <petite.abeille@...>
- Date: Tue, 1 Feb 2005 13:49:53 +0100
In her seminal novel "Story of O", Pauline Réage graphically highlights
the main tenet of Object Oriented Programming (OOP): 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 and agreed upon
vocabulary: class, object, instance, method, etc...
While not object oriented per se, Lua can be viewed be as a canvas of
sort on which to write an OOP story.
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
object oriented system in Lua out-of-the-box simply by naming it so.
Here is an abridged and PG rated version of "Lua's Story of O":
On the First Day, there was "thisClass":
local thisClass = superClass.inherit( superClass )
Which "inherited" all its behavior from "superClass":
local superClass = Object
On the Second Day, came the "new" instance:
thisClass.new = function()
-- instantiate the super class
local super = superClass.new()
-- inherit the super class instance methods
local this = super.class().inherit( super )
end
On the Third Day, came the "method":
this.justDoIt = 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 declared an extended weekend and there was
much rejoicing through the land.
Or so the story goes...
See attachment for the graphical details of a diminutive object
oriented system, known as "LU" in some circles.
Cheers
--
PA, Onnay Equitursay
http://alt.textdrive.com/
Attachment:
LU.tar.gz
Description: Binary data