I suggest this improvement for more correct OOP in Prototype.

var Class = {
  create: function() {
    return function() {
      this.initialize.apply(this, arguments);
    }
  },

  from: function(base) {
    var klass = Class.create();

    //copy static attributes?
    for (var key in base)
      if (klass[key] !== base[key])
        klass[key] = base[key];

    //inherit but without initialize the new prototype!
    var F = function(){};
    F.prototype = base.prototype;
    klass.prototype =  new F;

    //correct constructor!
    klass.prototype.constructor = klass;

    //useful in future?
    klass.__base__ = base;

    return klass;
  }
}

var BaseClass = Class.create();
var MyClass = Class.from(BaseClass);
var obj = new MyClass;
obj instanceof BaseClass => true!


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to