> I abhor this syntax. I wish I could put it any more mildly.

Haha! Actually, I'm quite fond of it, but I can see how it could be
misleading.

> I hesitate to do this because of the burden of backwards
> compatibility. Any static method called "extend" would simply stop
> working. We can't break code that's worked in every version of
> Prototype since 1.0. (You could also make this argument about
> "parent," but my gut feeling is that "extend" is a far more common
> name for a method.)

Although I don't particularly like this notation, I think we could
code around backward compatibility issues by special casing
Class.create not add the class method "extend" if it's called without
any arguments.

> I also like the fact that Class.extend and Class.mixin would mirror
> the existing Object.extend and a proposed Object.mixin (which would
> work the same way as Object.extend, but wouldn't overwrite already-
> defined properties on the destination object). Of course, Tobie seems
> to *hate* this, so we've got some stuff to sort out. :)

Just to clarify: I don't hate it, I just think that if the only thing
it does is obfuscate the fact that we are using prototypish
inheritance it's not woth adding them. i.e. if Class.mixin is nothing
more than Object.mixin(target.prototype, source).

I more in favor of being able to add mixins during class creation (via
a *magic* property name) and be sure that they don't overwrite
instance methods.

Idealy, this would mimick ruby implementation, where you can still
access the mixin's method using this.$super (the implementation I
posted a while ago did that).

To summarize:

I would like to have the following magic properties:

- ClassMethods (or $Class, $ClassMethods, $class)
- Include (or $Include $Mixin or $include)
- Alias (or $Alias, $alias)

Access parent instance methods or shadowed mixin's with this.$super
(or this.sup or this.uber, but not this.parent)

Have it consistent: i.e. either we use $ everywhere or we don't.

For example creating a new "Cow" class whose parent is "Animal":

var Cow = new Class(Animal, { // or Class.create(Animal, {...
  ClassMethods: {
    count: 0,
  },
  Include: [Eatable, Breedable], // these are mixins
  initialize: function(age, owner) {
    this.sup('cow', age, owner);
  },
  talk: function() {
    return 'meuuuh';
  },
  eat: function(food) {
    // eat food
  },
  Alias: {
    talk: ['say', 'speak'],
    eat: 'feed'
  }
});




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