This is good stuff!  I think the syntax is just about perfect, and even
though it doesn't involve inheritance, I *love* that I'll be able to pass a
hash of methods directly to Class.create() (or Class.extend()).

I'm perfectly happy using this.parent() since "super" is reserved.  I can't
think of anything better, and I definitely wouldn't want it cluttered with a
"$" prefix.

My thoughts on the "magic":  If the implementation of Class.inherit() didn't
depend on the "subclasses" property, I would say it is too much magic. I
just can't think of a situation where I would need it.  However, I see that
the implementation requires it, and it really doesn't bother me.  I don't
think there is enough risk of naming conflict to necessitate a prefix.

The only feature request I have is for a convenient way to alias methods.
Object.extend() does okay for this, but I'd rather keep it in the class
definition.  Something like this:

var Cat = Class.create({
  talk : function() { return "meow" },
  aliasMethods : {
    speak : "talk",
    saySomething : "talk"

If there is any interest, I'd be happy to write up a patch for it.

Quick question on the "superclass" property:  For the negative test on line
320, should the superclass is referenced using
pet.constructor.superclassrather than

- Adam

On 6/23/07, Andrew Dupont <[EMAIL PROTECTED]> wrote:
> We've been working on a more robust class-based inheritance model,
> fashioned after Dean Edwards's Base and others like it. There's an
> inheritance branch in the SVN repository that shows our latest
> efforts.
> We've had some lively internal discussions about syntax. I figured I'd
> hold my finger to the wind and see how the list feels about some of
> these issues.
> First, go to <
> branches/inheritance/test/unit/base.html> and take a look at the
> handful of unit tests we've written for inheritance. The fixtures
> start at line 60 (Animal, Cat, Mouse) and the tests start at line 315.
> Next, consider these questions:
>   1. Does the current API make sense? Was there anything about it that
> surprised you? Anything you'd add or remove?
>   2. Does "this.parent()" make sense as a way of calling the
> superclass's method? (We can't use the word "super" because it's
> reserved in JavaScript).
>   3. Right now there are a few "magic" properties in class instances:
> "superclass," "subclasses," and "parent." Is this too much magic? Not
> enough magic? Do you think these are likely enough to conflict with
> existing properties of a class that it's worth namespacing them
> somehow? ($superclass, $subclasses, $parent, etc.)
> Feel free to make feature requests or ask other questions. Kudos to
> Alex Arnell's inheritance scheme <
> inheritance/> for getting all of this started.
> Cheers,
> Andrew
> >

You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at

Reply via email to