lua-users home
lua-l archive

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


skaller wrote:
On Mon, 2005-01-17 at 04:07, André de Leiradella wrote:


The thing the bothers me most is how to call inherited methods.


An object is nothing more than a table of closures. OO is just a minor subset of functional programming.

Inheritance is no problem, just modify the table
in the derived class .. which is just a function
that calls the base function first to
make the initial table.

function base(x) return { ["meth1"] = function () return x end;
    ["meth2"] = function () return 2 end
  }
end

[...]

Note -- no 'self' argument is needed,
the private variables of a class can be
refered to directly in the method without
any 'self'. Also no metatables or environments
(whatever they are) are needed.
All you need is lexically scoped functions and tables,
Lua already has both.

How do you refer to object slots defined by parents?

How do you do super dispatch?

Jay