[Prototype-core] Re: Superclass constructor

2007-09-28 Thread Mislav Marohnić
On 9/28/07, Matt Foster <[EMAIL PROTECTED]> wrote: > > > What exactly is the "$super" argument and why does it always have the > dollar sign in front of it? It has the dollar sign in front because "super" is a reserved keyword in JavaScript. "$super" was the next best thing. Prototype looks whic

[Prototype-core] Re: Superclass constructor

2007-09-28 Thread Matt Foster
More support for the non-automatic constructor team, a lot of my classes do not have constructors, they're abstract, this functionality would fubar so much of my code. On Sep 28, 11:24 am, "Nicolás Sanguinetti" <[EMAIL PROTECTED]> wrote: > I'm not gonna say to you that if you have something c

[Prototype-core] Re: Superclass constructor

2007-09-28 Thread Matt Foster
I have a question about the 1.6 inheritance model. What exactly is the "$super" argument and why does it always have the dollar sign in front of it? Is the super a reference to the super class's prototype object or is it an instance of the super? Cheers, Matt On Sep 28, 11:24 am,

[Prototype-core] Re: Superclass constructor

2007-09-28 Thread Ryan Gahl
Sorry, you're right, I was just going down the path of teacher, guiding the OP (who mentioned destructors first) towards a "Disposable" abstract class to inherit from... On 9/28/07, Mislav Marohnić <[EMAIL PROTECTED]> wrote: > > On 9/28/07, Ryan Gahl <[EMAIL PROTECTED]> wrote: > > > > Oh yea...

[Prototype-core] Re: Superclass constructor

2007-09-28 Thread Mislav Marohnić
On 9/28/07, Ryan Gahl <[EMAIL PROTECTED]> wrote: > > Oh yea... it's definitely not a core thing as it depends on an app's > object and domain model. This was kind of just an aside conversation that > popped up I think :) Well, it sounded like a core request at first. Your "destructors" are ordin

[Prototype-core] Re: Superclass constructor

2007-09-28 Thread Ryan Gahl
Oh yea... it's definitely not a core thing as it depends on an app's object and domain model. This was kind of just an aside conversation that popped up I think :) On 9/28/07, Nicolás Sanguinetti <[EMAIL PROTECTED]> wrote: > > > I'm not gonna say to you that if you have something complex calling >

[Prototype-core] Re: Superclass constructor

2007-09-28 Thread Nicolás Sanguinetti
I'm not gonna say to you that if you have something complex calling "destructors" isn't correct. I'm just gonna argue against it being in core, as IMHO it's something that not really many people need, and, since you have to call it manually, the best you can do is defining a naming convention, not

[Prototype-core] Re: Superclass constructor

2007-09-28 Thread Ryan Gahl
Alex, javascript has its own garbage collector, sure... but firstly, it's not a consistent implementation across browsers. This is an ancient problem as far as Ajax development goes. Secondly, the apps I develop (and more people are starting to get into) are highly complex, long running single page

[Prototype-core] Re: Superclass constructor

2007-09-28 Thread Alex Arnell
On Sep 24, 1:16 pm, "Les Szklanny" <[EMAIL PROTECTED]> wrote: > Yes, the destructor needs to be called manually, but calling it > eliminates possible memory leaks. > > See below a destructor for the marker (pin) object that you see on a > map. This destructor also destroys the events object, wh

[Prototype-core] Re: Superclass constructor

2007-09-24 Thread Les Szklanny
Yes, the destructor needs to be called manually, but calling it eliminates possible memory leaks. See below a destructor for the marker (pin) object that you see on a map. This destructor also destroys the events object, which is a property of marker. /** * APIMethod: destroy * De

[Prototype-core] Re: Superclass constructor

2007-09-24 Thread Ryan Gahl
via the object model abstraction layer we have in our framework - so at that level it's a manual call, but by using the framework it's managed and for all intents and purposes automatic via a custom app garbage collector. Then again, we have an XML layer to represent widgets as finite state machine

[Prototype-core] Re: Superclass constructor

2007-09-24 Thread Jeff Watkins
How would you implement a destroy or destructor function since JavaScript doesn't support it? Do you manually call the method? On Sep 24, 2007, at 11:24 AM, Les wrote: > > Ryan, > > Did you notice that each OpenLayers class has a destructor (destroy) > and a property denoting the class name? >

[Prototype-core] Re: Superclass constructor

2007-09-24 Thread Ryan Gahl
I use something similar in WebWidgetry's object model (dispose in my case instead of destroy)... never saw OpenLayers. On 9/24/07, Les <[EMAIL PROTECTED]> wrote: > > > Ryan, > > Did you notice that each OpenLayers class has a destructor (destroy) > and a property denoting the class name? > > I do

[Prototype-core] Re: Superclass constructor

2007-09-24 Thread Les
Ryan, Did you notice that each OpenLayers class has a destructor (destroy) and a property denoting the class name? I don't see such a destructor in Prototype or Dojo, see below: OpenLayers.Map = OpenLayers.Class({ initialize: function (div, options) { }, destroy:function()

[Prototype-core] Re: Superclass constructor

2007-09-24 Thread Ryan Gahl
Les, everyone is correct in stating there are inherent problems (or issues to be aware of) with multiple inheritance. However, it is certainly handy when you really need it (and know what to be careful of). Again, feel free to check out the inheritance model I use ( http://www.someelement.com/2007/

[Prototype-core] Re: Superclass constructor

2007-09-22 Thread Nicolás Sanguinetti
On 9/22/07, Les <[EMAIL PROTECTED]> wrote: > The OpenLayers API 2.5 (a maping API in part based on Prototype) > supports multiple inheritance, so why not Prototype? Mislav said: > Also, multiple inheritance isn't all that good. There is a reason Java and > C++ successors like Objective-C and C#

[Prototype-core] Re: Superclass constructor

2007-09-22 Thread Les
The OpenLayers API 2.5 (a maping API in part based on Prototype) supports multiple inheritance, so why not Prototype? http://openlayers.org/download/ See the Class.js file in BaseTypes. I pasted a fragment from Class.js: /** * Constructor: OpenLayers.Class * Base class used to construct all

[Prototype-core] Re: Superclass constructor

2007-09-22 Thread Robert Katić
On Sep 22, 1:16 am, "Les Szklanny" <[EMAIL PROTECTED]> wrote: > Do we support multiple mixins as > in Dojo? How do I invoke constructors of these mixins? There is no sense to invoke constructor of mixins (in Dojo is not invoked too): How to support mixins in Prototype? Goo question. We can de

[Prototype-core] Re: Superclass constructor

2007-09-21 Thread Mislav Marohnić
On 9/22/07, Les Szklanny <[EMAIL PROTECTED]> wrote: > > Ok, so there's a single supercalss. Do we support multiple mixins as > in Dojo? How do I invoke constructors of these mixins? Mixins shouldn't have constructors because they're, well, mixins. You have to think outside the scope of Dojo her

[Prototype-core] Re: Superclass constructor

2007-09-21 Thread Les Szklanny
Ok, so there's a single supercalss. Do we support multiple mixins as in Dojo? How do I invoke constructors of these mixins? http://dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo/object-orientation/mixins Les On 9/21/07, Mislav Marohnić <[EMAIL PROTECTED]> wrote: > On 9/2

[Prototype-core] Re: Superclass constructor

2007-09-21 Thread Mislav Marohnić
On 9/22/07, Les <[EMAIL PROTECTED]> wrote: > > > Mislav, > > The debate is not quite resolved for me. How do I use $super in case > of multiple inheritance? What made you believe we support multiple inheritance? This is a simple OO model we're building here. We aren't making C++ in JavaScript, w

[Prototype-core] Re: Superclass constructor

2007-09-21 Thread Les
Mislav, The debate is not quite resolved for me. How do I use $super in case of multiple inheritance? Let's say Cat inherits from Animal and Pet. How do I call Pet constructor in Cat? Les On Sep 20, 11:39 am, "Mislav Marohnić" <[EMAIL PROTECTED]> wrote: > On 9/20/07, Les Szklanny <[EMAIL PR

[Prototype-core] Re: Superclass constructor

2007-09-21 Thread Richard Quadling
On 20/09/2007, Mislav Marohnić <[EMAIL PROTECTED]> wrote: > On 9/20/07, Les Szklanny <[EMAIL PROTECTED]> wrote: > > > > But, shouldn't have to do this or use $super(name). The superclass > constructor should be called automatically (as in Dojo for example). > > We have modeled OOP support in Proto

[Prototype-core] Re: Superclass constructor

2007-09-20 Thread Mislav Marohnić
On 9/20/07, Les Szklanny <[EMAIL PROTECTED]> wrote: > > > But, shouldn't have to do this or use $super(name). The superclass > constructor should be called automatically (as in Dojo for example). We have modeled OOP support in Prototype based on the most traditional inheritance model. Most of th

[Prototype-core] Re: Superclass constructor

2007-09-20 Thread Les
The missing 'this' is just my typo :) I see your point about being able to control if and how the superclass constructor is called. Interestingly, the Dojo team apparently believes that eliminating this control reduces the size of boilerplate, see this: http://dojotoolkit.org/book/dojo-book-0-9/

[Prototype-core] Re: Superclass constructor

2007-09-20 Thread Ryan Gahl
Except i believe you really want call() here and not apply(), as you are not giving the base constructor the instance reference being acted upon. If "this" is used within the base class constructor, you'd run into problems. In your case what you want is something like Animal.prototype.initialize.ca

[Prototype-core] Re: Superclass constructor

2007-09-20 Thread Jeff Watkins
Actually, having the constructor called without your control could be disastrous if the constructor of your base class doesn't accept the same arguments as your derived class. Many languages use static analysis to determine whether you've explicitly called your base class' constructor, and

[Prototype-core] Re: Superclass constructor

2007-09-20 Thread G Jones
On Sep 20, 3:35 pm, "Les Szklanny" <[EMAIL PROTECTED]> wrote: > Oh boy... what happened to the principle of least surprise? :) People will be surprised by different things. I'd be surprised if it were called by default (PHP doesn't do that...)- how would stopping it work? Greg --~--~

[Prototype-core] Re: Superclass constructor

2007-09-20 Thread Les Szklanny
Oh boy... what happened to the principle of least surprise? :) I can invoke the superclass constructor by adding this line: Animal.prototype.initialize.apply(arguments); But, shouldn't have to do this or use $super(name). The superclass constructor should be called automatically (as in Dojo for

[Prototype-core] Re: Superclass constructor

2007-09-20 Thread Nicolás Sanguinetti
You have to pass $super to the subclass' methods as its first argument and then call it from there. var Cat = Class.create(Animal, { initialize: function($super, name) { $super(name); alert('Cat : initialize'); } }); Best, -Nicolas On 9/20/07, Nicolás Sanguinetti <[EMAIL PROTECTED]> wro