Javascript is an expressive language. You can achieve what you are asking without baking it into the method like that, you just have to stop trying so hard to do things in one function call (it's ok to have 2 function calls to achieve something that is a composite of two simpler steps). And by leaving our illustrious lower-level prototype functions as they are, it supports comfy use for those cases where the extra functionality is not needed (i.e. where only that first function call is required). Once you use prototype for about a year you will learn to like the fact the the core functions are left simple. So while I'd love to see my version of Object.inherit included in the core, I would not want Object.extend to change, nor would I want Class.create() to change.
As for the Observable/Observer thing, did you check out my other blog post on EventPublisher? If you need that functionality, you may that interesting as well: http://www.someelement.com/2007/03/eventpublisher-custom-events-la-pubsub.html On 4/2/07, Yanick <[EMAIL PROTECTED]> wrote: > > > On 2 avr, 11:42, "Ryan Gahl" <[EMAIL PROTECTED]> wrote: > > > This sounds good, in theory, but only if everything is declared inside > > > the inditialize function. > > > > Which is as it should be if your are really talking about class methods > (i.e. > > instance only members). > > > > See my blog post on this subject, which offers up a nice, prototype-y > > inheritance model and leave Object.extend alone (because it is useful as > is > > for bulk object property copying in other places besides inheritance): > > > > http://www.someelement.com/2007/03/multiple-inheritance-with-prototyp... > > > > I also speak to the whole "true" class level member issue and address > the > > bad habit of tacking said members statically onto the object's > prototype. > > The first part of the post does give examples using that way, just > because I > > know that's what people are used to. > > > > Give it a read. Object.inherit is very useful. > > > Yes, I just tried it, and it works nicely. I wrote some Observable/ > Observer generic classes that other classes may extend to benefit from > an Observer pattern to test the functionality (java-like). > > Though, I was wondering the possibility to write some sort of > Class.create(); with parameters.... something like : > > var Class1 = Class.create( baseClass /* , baseFuncName */ ); > > for single inheritance, or : > > var Class1 = Class.create( [ { baseClass: baseClass /*, baseName: > baseFuncName */ }, ... ] ); > > for multiple inheritance. > > Perhaps even add, as last parameter, an object to set as prototype, > and yet get rid of every Object.extend(). Such as : > > Class.create( prototype ); // for no inheritance > Class.create( baseClass, prototype ); // or Class.create( baseClass, > baseName, prototype ); > and > Class.create( baseClassArray, prototype ); > > (Is that going too far ?) > > I'm asking before throwing myself in anything, as you probably had > thought about it. Thanks though for the article, it was very > instructive. > > -yanick > > > > > -- Ryan Gahl Application Development Consultant Athena Group, Inc. Inquire: 1-920-955-1457 Blog: http://www.someElement.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
