[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-03 Thread Jerod Venema
On Thu, Jul 3, 2008 at 10:28 PM, Ryan Gahl <[EMAIL PROTECTED]> wrote: > Why are you calling >> shared instance members (where member is property/method) "static"? > > > Sorry, that's not what I meant to say. If you read my blog post ( > http://www.someelement.com/2007/03/multiple-inheritance-with-

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-03 Thread Ryan Gahl
> > Why are you calling > shared instance members (where member is property/method) "static"? Sorry, that's not what I meant to say. If you read my blog post ( http://www.someelement.com/2007/03/multiple-inheritance-with-prototypejs.html) - I explain what I mean by "prototype-static". Ok, let's

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-03 Thread kangax
On Jul 3, 10:34 am, "Ryan Gahl" <[EMAIL PROTECTED]> wrote: > Javascript does not have classes, true. Javascript does have instance > variables, and does have static members (where in the world are you getting > this stuff). You're kind of saying "javascript is not object oriented", > which it i

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-03 Thread Ryan Gahl
> > Kangax's point might be moot for simple constructors, but that doesn't > make it "plain wrong". Suppose you have a constructor with 100 > methods and you want 100 instances, is it better to define each and > every method on each and every instance, or put them on the > constuctor's prototype?

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-03 Thread RobG
On Jul 3, 4:09 pm, "Ryan Gahl" <[EMAIL PROTECTED]> wrote: > > Constantly repeating how I'm "plain wrong" and > > making up assumptions about my reasonings, my experience and skills is > > not something I would expect of you. > > You are saying things about a pattern that are wrong, and there's n

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-02 Thread Ryan Gahl
> > Constantly repeating how I'm "plain wrong" and > making up assumptions about my reasonings, my experience and skills is > not something I would expect of you. You are saying things about a pattern that are wrong, and there's no other kind of wrong other than plain :). The only thing I said th

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-02 Thread kangax
Ryan, no need to get offensive about patterns that work for you (and your team). I am certainly not throwing pointless arguments about some hypothetical performance issues. Everything I said comes from experience in applications I have worked on. It also comes from people who worked on JS applicat

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-02 Thread Ryan Gahl
> > It's gotten a bit testy, but I just wanted to say that I, for one, > have appreciated the discussion thus far ;-) Sorry about the feistiness, but glad someone is finding it valuable. --~--~-~--~~~---~--~~ You received this message because you are subscribed to

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-02 Thread Ryan Gahl
Just re-read my last post - kangax, sorry for getting all "DUDE!!" on you... I'll try to keep my tone down if we continue the exchange :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-02 Thread Ryan Gahl
Seriously, stop with the performance stuff - it's not an issue. You keep bringing it up and I'm here to tell you it's just plain wrong. And my example is a perfect example of the benefit of the assignment of instance members within the constructor as rule. In fact, in this example, it's the ONLY wa

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-02 Thread kangax
I'm not sure what this has to do with anything. If a person doesn't know what Class.create does with an object (passed to it), it's their problem ; ) Bending language (and clogging performance) to meet inept programmers expectations doesn't seem like a wise thing to do. Adapting a "private members

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-02 Thread Dan Dorman
It's gotten a bit testy, but I just wanted to say that I, for one, have appreciated the discussion thus far ;-) :Dan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this g

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-02 Thread Ryan Gahl
One more little illustration: var blah = Class.create({ someArray: [], initialize: function() {} }); var foo1 = new blah(); var foo2 = new blah(); foo1.someArray.push("blahblah"); alert(foo2.someArray.length); //alerts 1, most people new to js will expect 0 How many times has this issue been pos

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-02 Thread Ryan Gahl
> > I would appreciate if my reasonings weren't claimed to > be "FUD" : ) I said "borderline FUD" :) And ok. It's not FUD. It's just not correct. But once again I disagree with both statements, where you say private members destroy any features of javascript. In fact, they are implemented by

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-02 Thread kangax
On Jul 2, 3:36 pm, "Ryan Gahl" <[EMAIL PROTECTED]> wrote: > > It's obviously a matter of priorities. For me, performance is usually > > one of the key factors. Simulating "private" properties (in a highly > > dynamic language) does not compensate for the decreased speed. > > But, there is no dec

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-02 Thread Ryan Gahl
> > It's obviously a matter of priorities. For me, performance is usually > one of the key factors. Simulating "private" properties (in a highly > dynamic language) does not compensate for the decreased speed. But, there is no decreased speed noticeable, is what I'm saying. So you're sacrificing

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-02 Thread kangax
On Jul 2, 1:12 pm, "Ryan Gahl" <[EMAIL PROTECTED]> wrote: > Of course there are. To say otherwise is confusing. I'm not sure I understand what you mean, Ryan. JavaScript doesn't have a notion of "static" (except for a reserved keyword that's not even implemented). There are "direct" members an

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-02 Thread Ryan Gahl
> > There are no "static" or "instance" methods on js objects really : ) > I understand what you mean, but it just sounds confusing. Of course there are. To say otherwise is confusing. You could do that, though "fat" constructors is usually not a good > idea. It would also cripple performance if

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-02 Thread Antoine Quint
Hi, On Jul 2, 2008, at 18:36 , kangax wrote: >> Prototype doesn't provide any special facility for defining "static" > members (as majority defines it). All it takes is to declare them as > members of "class" function. > > var Foo = Class.create({ ... }) > Foo.blah = 'my static property'; Yeah,

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-02 Thread kangax
On Jul 2, 11:43 am, Antoine Quint <[EMAIL PROTECTED]> wrote: > On Jul 2, 2008, at 17:27 , Ryan Gahl wrote: > > > Nowhere on that page does it say that static class methods are > > copied to the prototype. > > I think there are only ever static class methods passed in > Class.create(). When you d

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-02 Thread Antoine Quint
On Jul 2, 2008, at 17:27 , Ryan Gahl wrote: > Nowhere on that page does it say that static class methods are > copied to the prototype. I think there are only ever static class methods passed in Class.create(). When you do this: Class.create({ initialize: function() { // some code h

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-02 Thread Ryan Gahl
Nowhere on that page does it say that static class methods are copied to the prototype. If, for whatever reason, it actually IS supposed to work that way, it's a major flaw, and should be fixed immediately. But like I said, it wouldn't make any sense if it worked like that, and so it doesn't. So,

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-02 Thread Antoine Quint
On Jul 2, 2008, at 17:11 , Ryan Gahl wrote: > Why would Class.create() copy static class members to the prototype? > That doesn't make any sense. That completely rules out the > possibility that the developer, you know, wanted them to remain > static... As far as I know, that's how Class.c

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-02 Thread Ryan Gahl
Why would Class.create() copy static class members to the prototype? That doesn't make any sense. That completely rules out the possibility that the developer, you know, wanted them to remain static... On Wed, Jul 2, 2008 at 10:08 AM, Antoine Quint <[EMAIL PROTECTED]> wrote: > > Hi Ryan, > >

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-02 Thread Antoine Quint
Hi Ryan, On Jul 2, 2008, at 17:01 , Ryan Gahl wrote: > It probably has something to do with the fact that you are defining > the getter/setter statically on the class itself, where in the > second example, you are actually defining them at the instance > level, which is what you want. I d

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-02 Thread Ryan Gahl
It probably has something to do with the fact that you are defining the getter/setter statically on the class itself, where in the second example, you are actually defining them at the instance level, which is what you want. In your first example, I'll bet if you just do MyClass.test = "blah" it w

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-02 Thread Antoine Quint
Hi Darrin, On Jul 2, 2008, at 16:28 , darrin wrote: > Interesting, first time I've seen this. The alert is actually coming > out of Class.create call. What about this > > var MyClass = Class.create({ > initialize: function() { >this.__defineGetter__('test', function() { > alert('in

[Rails-spinoffs] Re: Mixing In JS Getters and Setters with Class.create

2008-07-02 Thread darrin
Interesting, first time I've seen this. The alert is actually coming out of Class.create call. What about this var MyClass = Class.create({ initialize: function() { this.__defineGetter__('test', function() { alert('inside getter'); return 'foo'; }); this.__defineSet