Hey Alex, et al.,

I'm inclined to agree with Jeff on this point, so I hope there's a way
of making the syntax sweeter.

> Yes, the very first version I wrote did in fact do that. I changed it
> on the advice of some friends after they looked at the syntax.

Do you remember what offended your friends?  The name of the 'self'
parameter is completely flexible, so that much can be left up to
individual style.  I happen to like the following (although I
understand the self-as-Class idiom derives from Ruby):

var Person = Class.create(function(Person) {
    Person.classMethod = function() {...};
    ...
})

Anyway, to each his own.  I'm guessing your friends balked at the
self.prototype.instanceMethod = function() {...} syntax.  That bit can
be improved, I think.  If you use the closure as a constructor for the
prototype object of the new class, then you can set instance
properties by referring to 'this':

var Person = Class.create(function(self) {
    self.classMethod = function() {...};
    this.instanceMethod = function() {...};
})

This also eliminates the need to return anything from the closure.  If
there's any interest in this approach, I can cook up a diff.

Ben


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