http://www.perlmonks.org?node_id=565609


in reply to Inheritance: the root of the problem

Decide how you want inheritance to work, and you can implement it with closures. It won't even take much work. Since closures and OO programming are pretty much orthogonal concepts, there isn't really a natural closure way to do OO. They are pretty unrelated concepts. I like to say it as, "OO is about creating good nouns and closures are about creating good verbs." They are just different ways of thinking about the problem.

The first time I tried to implement an object model with closures was at Re (tilly) 1: Nested Classes. As you can see, it is quite simple. (However I picked a simple model to implement.) At A Cat's eye view of OO you'll find an explanation of that particular inheritance model. If you want some more ideas, there is no shortage of places to look. The Perl 6 design notes, the object models of other languages, CLOS, and so on.

What do YOU want an object model to do for you?

  • Comment on Re: Inheritance: the root of the problem

Replies are listed 'Best First'.
Re^2: Inheritance: the root of the problem
by apotheon (Deacon) on Aug 04, 2006 at 07:52 UTC

    Decide how you want inheritance to work, and you can implement it with closures.
    That's just it — I don't know yet, and it's the question I seek to answer by way of this discussion (or, at least, a question I seek to get closer to answering by way of this discussion). There are many here at PerlMonks who know great gobs more about OOP and inheritance-like mechanisms than I, and I seek their (your) wisdom.

    print substr("Just another Perl hacker", 0, -2);
    - apotheon
    CopyWrite Chad Perrin