Parent: Please don't overuse the $ sign. It should be used for utilities and nothing else. Don't mix it in other areas, such as classes.
Saying that, i still think it is good to introduce a "parent" property .. To make it more convenient, name it "parentClass". Easy to adopt and no dollar. Style: I prefer the style Tobie Langel posted, because "Class.create" means the same as "new Class", so saying "Class.create" is a bit verbose for that matter. "new" explains it all. How about this? var Animal = new Class({ initialize: .. }); var Cat = new Class({ extends: [Animal], initialize: .. }); "initialize" is reserved, why not "extends" too - allowing the "Class" constructor to automatically extend the new class by just looking at the content of "extends". I think this is pretty straight forward, instead of using a new method for everything.. (create, add, extend) It should work "by definition". On 6/25/07, DK <[EMAIL PROTECTED]> wrote: > > > > On Jun 25, 7:50 am, Andrew Dupont <[EMAIL PROTECTED]> wrote: > > On Jun 24, 7:48 pm, Tobie Langel <[EMAIL PROTECTED]> wrote: > > > > > I personally prefer the following syntax: > > > > > var Animal = new Class({ > > > ... > > > > > }); > > > > > var Cat = new Class(Animal, { > > > ... > > > > > }); > > > > I abhor this syntax. I wish I could put it any more mildly. > > > > In languages with class-based inheritance, class creation and class > > instantiation are two separate concepts. Defining a class is done > > within a control structure. I can think of nothing more confusing than > > instantiating Class to create your class, then instantiating your > > class to create an instance of the class you just instantiated with > > Class. > > Yes, but JavaScript is different. The class is really a (function) > object in JavaScript - it isn't common, but this makes JavaScript a > very flexible language. We can't compare JavaScript in everything to > other OO languages. > This approach (using new) is very interesting and innovative for > me :-) > But other solutions are pretty too :-) > > > > Also, I think that this.sup or this.$super would be safer than using > > > this.parent, which, in the realm of DOM scripting might be used pretty > > > often inside classes already. > > > > "this.$super" is fine with me > > "parent" is very popular name for an attribute. Please don't use it. > The most natural, IMHO, seems to treat all new attributes and methods > added by prototype as "magic" and prefix them with anything (as > prototype uses the dollar sign ($) frequently for added stuff, it > would be most natural choice again). > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---