Prototype Inheritance

See http://en.wikipedia.org/wiki/Prototype_based_programming for detailed information about prototype inheritance.

Summary
Prototype InheritanceSee http://en.wikipedia.org/wiki/Prototype_based_programming for detailed information about prototype inheritance.
otlib
CloneCreates a clone of an object.
ParentGets the parent of a clone.
IsACheck if a clone is inherited from another.
otlib.objectMerely serves as a convenient wrapper and root prototype.
CloneExactly the same as otlib.Clone.
IsAExactly the same as otlib.IsA.
ParentExactly the same as otlib.Parent.

otlib

Summary
CloneCreates a clone of an object.
ParentGets the parent of a clone.
IsACheck if a clone is inherited from another.

Clone

function Clone(base,
callable,
clone)

Creates a clone of an object.

Parameters

baseThe table to clone from.
callableAn optional boolean.  If true, __call is set on the clone and returns another clone.  If the function Init is defined, it will be called with whatever parameters are passed to __call.  Defaults to false.
cloneAn optional table to set as a clone, this value is what is returned.  Defaults to an empty table.

Returns

The table from the parameter clone.

Revisions

v1.00Initial.

Parent

function Parent(clone)

Gets the parent of a clone.

Parameters

cloneThe table clone that you want to know about.

Returns

A table or nil specifying the parent, nil if no parent.

Revisions

v1.00Initial.

IsA

function IsA(clone,
base)

Check if a clone is inherited from another.

Parameters

cloneThe table clone that you want to know about.
baseThe table clone to check against.

Returns

A boolean specifying whether or not clone is inherited from base.

Notes

  • Returns true if the tables are equal to each other (since a derived class IS A derived class, it makes sense).

Revisions

v1.00Initial.

otlib.object

Merely serves as a convenient wrapper and root prototype.

Summary
CloneExactly the same as otlib.Clone.
IsAExactly the same as otlib.IsA.
ParentExactly the same as otlib.Parent.

Clone

Exactly the same as otlib.Clone.

IsA

Exactly the same as otlib.IsA.

Parent

Exactly the same as otlib.Parent.

function Clone(base,
callable,
clone)
Creates a clone of an object.
function Parent(clone)
Gets the parent of a clone.
function IsA(clone,
base)
Check if a clone is inherited from another.
Close