this that selves

“How can different things look the same ?
I don’t know man, I didn’t do it.”

In OOP, self-reference of the Object is achieved with a
special keyword, typically this or self.


this resolves to the current object and the parent object.
Like, this.parent or super( this ) or $self->SUPER::.

Multiple Inheritance Or Which This is That

With multiple parents, this can refer to the wrong parent.

Single inheritance is preferred for this reason.

This is also called the diamond problem.

C3 solves this problem by taking into the account the ordering
of the parents.


Perl’s object model is inspired from python.

Roughly put, Methods == Functions, with a special first argument.

In perl you bless $stuff and in python you have,

class Foo(object):

this’s confusing !

In javascript, every function has a “this”.

This means you sometimes do,

function foo() {
        var that = this;
        // or var self = this;
        function bar() {

With callback functions, this becomes useful.

It’s painful to write an extra declaration, just like in
perl or python.

So I present to you selves, which makes writing declarations

<a href="">var yx = require('yx');</a>
    function foo() {
        var selfs = new yx.__selves();
        selfs().i.youShoudHaveDoneThat = function () {
            return "I Told You So!";
    = function () {
            test.equal(selfs().previous.youShoudHaveDoneThat(), "I Told You So!");
            this.doSomething = function () {
                console.log("But but ... !");

You should really be using the => from coffeescript.
Another approach is,

function foo() {
        function bar(x,y) {

You can install [yx] with npm install yx.
yx provides coffeescript’s internal methods like __extends for use in js.


#perl and #node.js from freednode.