On 27 sep, 12:22, "Mislav Marohnić" <[EMAIL PROTECTED]> wrote:
> On 9/27/07, Ryan Gahl <[EMAIL PROTECTED]> wrote:
>
>
>
> > ok, then it does work, my apologies :)
>
> Every implementation breaks if you use it wrong.
Talking about implementations, I understand why the proto team decided
to add $super as first parameter in the constructor, but how do you
handle calling an overriden method in the parent class ? Consider
this :
var Class1 = Class.create( {
initialize: function() {
this.value = 0;
},
foo: function() {
return ++this.value;
}
};
var Class2 = Class.create(Class1, {
initialize: function($super, startValue) {
$super(); // ok, useless here, but just for the sake of it...
this.value = startValue;
},
foo: function() {
return {parent class object}.foo()*2;
}
};
var bar = new Class2( 100 );
alert( bar.foo() ); // expected to return 202
Could it be possible to have this.superclass (or something) as the
reference to the parent class instead of having $super passed in the
constructor? This way, we change the Class2 constructor, and foo
method as :
initialize: function( startValue ) {
this.superclass();
this.value = startValue;
}
foo: function() {
return this.superclass.foo()*2;
}
Sorry if this matter has been discussed before, but would there be
issues with this kind of implementation ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype: Core" 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/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---