Ian Bicking: the old part of his blog

Re: Prototype and object prototype comment 000

You do defeat further inheritance like that.. however, in theory, you should be able to do it like this (which is one of the things I'm considering for the object model):

function isBoundFunction(func) {
    return (typeof(func.im_func) == 'function');
}

function bind(func, self) {
    var im_func = null;
    if (isBoundFunction(func)) {
        im_func = func.im_func;
    } else {
        im_func = func;
    }
    func = function () {
        return func.im_func.apply(func.im_self, arguments);
    }
    func.im_func = im_func;
    func.im_self = self;
}
Comment on Prototype and object prototype comment 000
by Bob Ippolito

Comments:

With return func; at the end, of course.

# Bob Ippolito

Ok, just tested it.. it works in practice. Check the new implementation in svn (which is very similar to this, but it has tests and stuff).

# Bob Ippolito