| |
| |
| |
|
Page: 1 2 3 4 5
Comments:
<0> only the first function works <0> the first alert <0> can anybody explain me why? <0> http://dumb.ro/problem.txt <1> VaranG|aN: yes, a bit <2> do you find any problems with FireFox.. such as ASP.NET components not working properly while using FireFox ? <2> FireFox Version 1.5 <1> never test under 1.5, but i don't have any problem with <1.5 <0> is this reffering to the scope from where the method was called? <1> sk8ing: you don't have this.something. something is a private var in this case <0> and if it would be this.something = 'lala'l <0> it would have been this.something? <1> that is public var <0> I know that's a public var, but I don't think that the method cares about that <0> cuz it's a member method so it has access to everything inside the object <1> if you have problem. it means it care
<1> since i never mess up my var name liek that, i never run into those problem <0> that's messing up? <1> having both something and this.something <0> I'm not having both <0> I'm having only a private one <0> and I'm stuned by the fact that this.something is undefined <1> it is perfectly make sense <0> no, it's not. this is a reference to the current object since that's a method, it's not in the definition space/constructor <0> this means that you can define public properties from a method <1> but you declare it as private <0> I mean if you have this.myMethod = function() { this.aaaa = 'sdafsd'; } <0> aaaa will become a public property <0> maybe I'm just not used to this kind of OO approach <0> but it seems wrong in so many ways <1> there is no right or wrong, every language is different, as long as your OO knowledge is strong, you won't have problem with the syntax <1> I can write OO like stuff in flash5 <0> never played with flash <0> the thing is that a member method has to have access to all the private and public properties, externaly or internaly <0> this would be an external pointer to the object <0> that's why it's undefined, cuz the function sees it's own object externaly <0> with external access right <0> wich is wrong <1> to make things more clear, there is no private var in js, it is a local scope var, it kind of behave like a private var <0> and what is this.xx? <0> is still local scope <1> no. that is public property <0> :/ <0> local scope, global scope. public, private <0> public properties are still in local scope <1> local scope to the object instance <0> yes <0> what I'm saying is that "this" referrenced from a member function should be give public access to all it's properties/methods <0> since the method itself is a member of the object <1> that is not what js provide you <0> I can see that <0> it makes good design impossible <1> .... <0> since you can't have member functions that play with objects of the same type <1> you asking for bad thing, I don't want to be bound by type now <0> for example function obj1() { var x = 1; this.y = x; this.add(lala) { x += lala.x; } } a = new obj1; b = new obj2; a.add(b); <0> this is impossible to do <0> sorry b = new obj1 <1> BAD <0> no <0> it's not bad <1> you asking public method to access another object private var directly <0> that's how all real languages are managing it <1> no <0> no <0> it's a member method <0> it doesn't matter that it's public or private <1> lala.y <0> what's with it? <1> it is a bad design from the begining <0> this is good design <0> bad design is as it is right now <0> cuz you are forced to define x as public <1> you need to have better grip on public and private , isolation etc <0> I think I know a lot about OO <1> your add method is trying to read lala's private x , how's good it is?
<0> lala is of the same type <0> if it's not of the same type it should throw an error <1> it doesn't matter <0> of course it does <1> bad is bad <0> that's how it's done in most languages <0> else you wouldn't be able to have a lot of stuff <1> It doesn't mean it is good, I never do that myself <0> of course it's good <0> else you wouldn't have any private property <0> everything would be public <0> so you could be able to do obj_instance1 = obj_instance2; <0> another thing that you can't do in js <3> what now? <3> Are we talking about anything interesting? <1> not interesting at all :D <0> ... <3> goodie, I'm was too lazy to read up <0> I'm talking about how screwed up the OO in js is <1> [13:39] <0> for example function obj1() { var x = 1; this.y = x; this.add(lala) { x += lala.x; } } a = new obj1; b = new obj2; a.add(b); <0> b = new obj1; <1> he whining about that and think it is a good design <0> ht311: omg <0> man stop saying it's bad design <0> I'll show you 1000000000 source files that will show you that it's good design <0> that's how objects are ment to be used <3> What does that have to do with anything!? <1> you need to can fb comment , my comment stay [13:44] <1> your add method is trying to read lala's private x , how's good it is? <1> even it is same type, i won't do it like that <3> well, beeing the same 'type' you should be able too. <0> and I've said: the type is the same <0> thank you fatbrain <3> sk8ing: doesn't mean I think you should in JS. <1> you able to, but should you do it <0> ht311: yeah, that's how you copy an object <0> or do operations <0> + operator <0> - operator <3> eh, not really. <1> not really needed, in .net, you don't do it liek that <0> not allweays <1> so, js is fine as is <3> sk8ing: that operator example you just wrote is not js, that would be something one would exect in C++. <0> fatbrain, I know, I was pointing out that this limitation in js makes stuff like that impossible <3> And JavaScript is not C++. <3> Tho some would like the JS-OOP to be more of a *real* OOP language. <0> that's why there is no default copy constructor <3> It's not a limitation. <0> and that's why you can't build a real one <1> ...... <3> var a = 23; b = a; <3> na, bad example :P <0> in fact... you can do a copy constructor <0> :P <3> Not in JavaScript. <0> you'll need two functions <1> nothting stoping you to write a.clone(b); <0> nah <0> a = b.clone(); <3> sk8ing: Still, that's not a copy *constructor* <0> I know <0> :P <0> but it's a clone <0> a real one <1> there are languages that you can't write operator <3> It's not a *real* clone. <3> var a = new foo(); var b = a.clone(); ***ert(b instanceof foo); would fail. <0> uhm of course it is: func x() { var x = 0; this.y = 1; this.clone() { ***ign(x,y); } ***ign(a,b) { x = a; y = b; } } <0> there you go <3> well, I just invalidated that. <3> and wtf is y in your example? <3> ***ign(x,y) <-
Return to
#javascript or Go to some related
logs:
karawetta #mysql #java #apache #javascript how to install fluxbox on centos Babylon6+problem synapsis poc #javascript #AllNiteCafe
|
|