My proposal is very simple:

  var Animal = Class.create(instanceMethods, classMethods)

Both arguments are hashes of methods and the second argument is optional.
There are *no* magic properties in them (like include, extends, mixin) -
every key-value pair becomes a regular method. The only "magic" property
still remains "initialize", which is the constructor by convention.

Subclassing:

  var Cat = Class.extend(Animal, instanceMethods, classMethods)

This is much smarter than "Animal.extend(...)" because you may wish to have
a class method named "extend" on your classes.

Other OO stuff:

  Class.include(Animal, Enumerable)
  Class.alias(Animal, ...)

So you see, I want to contain everything in "Class". By doing this we
simplify inheritance support code, greatly reduce the risk of collision and
ensure everybody is aware of what are they doing.

And the name of the superchaining method (by my order of preference):

   1. sup
   2. $super
   3. $parent

I vote against:

   - parent (naming collisions)
   - base (ugh!)
   - uber

In conclusion, my philosophy is:

   - no magic properties except "initialize"
   - keep the inheritance support code simple and short, otherwise it
   makes no sense in having it
   - leave room for users to make their own additions to the inheritance
   support code
   - no dollar-signs and underscores because they indicate bad design
   (exceptions from this rule are $super/$parent)
   - don't try to make defining of classes look like you're writing Ruby,
   it simply won't work.

This is some class definition in Ruby:

  class Cat < Animal
    include Enumerable
    alias :peach, :each

    def say
      "meow!"
    end

    def self.food
      super + ["birds", "gold fishes"]
    end
  end

You can't achieve this in JavaScript. Simply let it go.

--~--~---------~--~----~------------~-------~--~----~
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