World: r3wp
[!REBOL3]
older newer | first last |
Oldes 30-Nov-2010 [6357] | It's just the only difference I can see. |
Ladislav 30-Nov-2010 [6358] | We can implement semantically equivalent code in REBOL, but that exact code can't be made to work. - I do not understand - that code works, what does "that exact code can't be made to work" mean? |
BrianH 30-Nov-2010 [6359x2] | It looks like a question, based on the object model of JavaScript. REBOL objects don't have "children" in that way, as we don't do delegation, just prototyping. |
WhatIsYourSex has a function that is bound to the object *before* the word 'sex is added to it, so the 'sex it is getting is not person/sex. It only works for objects derived from it. Unless I missed Oldes' point, and only working in derived objects was intended. | |
Oldes 30-Nov-2010 [6361] | Of course this has no sense even in the JS version. The only difference is, that JS would return undefined, REBOL throw an error. The second is better for me. |
Ladislav 30-Nov-2010 [6362] | OK, so, generally - a nonsense, that actually works the way he wants it to, so what? |
Oldes 30-Nov-2010 [6363x2] | He wants to show this: JaneDoe = new Person("Jane", "Doe"); DoeJane = new Person("Doe", "Jane"); Person.prototype.sex = "Man"; JaneDoe.WhatIsYourSex(); JaneDoe.WhatIsYourSex(); |
in JS if you extend the prototype, you extend the already existing objects as well. | |
BrianH 30-Nov-2010 [6365] | The equivalent to what RT requests would be to extend person *after* JaneDoe is created, and then have JaneDoe work. JS supports this (in some circumstances). |
Ladislav 30-Nov-2010 [6366] | The equivalent to what RT requests would be to extend person *after* JaneDoe is created, and then have JaneDoe work. - why do you suspect him not being able to demonstrate the code he wants to work? |
BrianH 30-Nov-2010 [6367x3] | Unless I missed Oldes' point . |
I suspect that RT can't demonstrate the code that he wants to work because he doesn't even seem to be able to understand the difference between R2 and R3 objects, calling it syntactic sugar when it's not, even after it is explained to him. If he can't understand that, it is less likely that he will understand the difference between REBOL's and JS's object models. | |
I make a distinction between "doesn't" and "can't" when it comes to understanding. Only close-minded people "can't". | |
Oldes 30-Nov-2010 [6370x3] | I'm pretty sure he wants to show above functionality.. as he says: "extending an object instance from another one with make in rebol isn't exactly like javascript prototype property as js prototype allows to extend ALL instances at once." |
To get this functionality, the prototypes would need to know it's childrens. And extend them as well. The JS model is simply different. | |
In ActionScript it's common that you, for example, add functionality to all existing buttons. | |
BrianH 30-Nov-2010 [6373] | That can be done in REBOL, but it requires planning for it ahead of time and a bit of explicit redirection. This is done in the R3 GUI. |
Oldes 30-Nov-2010 [6374] | Although I use above from time to time, I don't like heavy class based code as I consider it very unreadable.. I've seen many such a (ActionScript) projects. |
BrianH 30-Nov-2010 [6375x3] | GUI frameworks tend to be a good place to use class-based or delegation-based OOP, as we do in the R3 GUI. |
And to a lesser extent in VID as well. | |
Styles are classes, which we explicitly delegate to. | |
Pekr 30-Nov-2010 [6378] | I did not read all your discussion, so sorry, but do you guys understand, what the JS prototype means? It simply means, that each object can have (or has), its prototype |
BrianH 30-Nov-2010 [6379] | REBOL has prototypes already. The JS .prototype also implements automatic delegation, and it was that feature he was asking about. |
Oldes 30-Nov-2010 [6380] | Also in JS, the newly created object hold the parent information - in __proto__ value: alert(DoeJane.__proto__); |
BrianH 30-Nov-2010 [6381] | That is not consistently so - it depends on the engine. |
Pekr 30-Nov-2010 [6382] | obj: context [ name: "Jane Dow" proto: context [ sex: 'male ] ] So, in above case, JS allows you to query: obj/sex ... and if no 'sex object field is found, then the accessor looks into the prototype subobject, which can be referenced ... and the chain continues. Just see: http://mckoss.com/jscript/object.htm |
BrianH 30-Nov-2010 [6383] | Yes, but that feature is not the "prototype" feature of JS's prototype-based OOP, it is the delegation feature. REBOL is prototype-based without delegation. |
Oldes 30-Nov-2010 [6384] | The above is wrong, the 'proto must be a pointer to the parent which you used to make the object.. in my REBOL code above it's the person object. |
BrianH 30-Nov-2010 [6385] | I really wish that JS had done a better job with its prototype model. Self and NewtonScript were better. |
Oldes 30-Nov-2010 [6386x2] | we could have something like: new: func[obj /local newObj][ newObj: make obj [] extend newObj '__proto__ obj newObj ] p: new person but as a native so as Pekr said, if value is not found in the object itself, it would look in the parent. |
the __proto__ should be hidden so it would not be visible on probe.. but again... I'm not sure we need it at all. | |
BrianH 30-Nov-2010 [6388] | Implicit anything is helpfull(?) for hiding stuff from developers, but since we can do stuff explicitly its lack doesn't make us disabled. And every implicit thing that we can't turn off reduces our flexibility - as demonstrated in the selfless debate. |
Pekr 30-Nov-2010 [6389] | Well, so maybe you educated guys could answer him ... but my opinion is, that I am not sure he will understand, he tends to be pretty stubborn to change his mind, even if things are explained to him ... |
Steeve 30-Nov-2010 [6390] | One could simulate a simple delagation behavior if Rebol had an intrinsic mezz when and error is processed. So that, in the intrinsic do-error, one could discard some errors and return a useful computed value in replacement. See what I mean ? |
BrianH 30-Nov-2010 [6391x2] | Direct binding, remember: Objects are independant of their prototypes. But we will see once object specs are implemented. |
I don't really see the point though. Explicit delegation is not hard to do, especially when you write accessor functions, like in the R3 GUI. | |
Pekr 30-Nov-2010 [6393] | BrianH - you can't solve it for the path notation though. If what Steeve writes would be possible, then it would be workable, because obj/nonexistant would be catched by the intristic mezz, where the error would be processed ... |
Steeve 30-Nov-2010 [6394] | That's the idea |
Pekr 30-Nov-2010 [6395] | However - I see it nearly as a coiccidence, that obj/nonexistant does not return none. IIRC, in some other cases, for the R2->R3 transition, we decided to return none instead an error ... |
BrianH 30-Nov-2010 [6396] | Basically, you want message-not-defined from Smalltalk and Self (I know it's got a different name, bear with me). |
Pekr 30-Nov-2010 [6397] | path notation for blocks returns none, if the element is not existant, but it returns error for the object type ... |
Steeve 30-Nov-2010 [6398] | That fits our need... |
Pekr 30-Nov-2010 [6399] | Steeve - but it looks strange to dispatch object access method via intrinsic general error dispatcher ... |
BrianH 30-Nov-2010 [6400] | The reason everything gets shoehorned into (the local equivalent of) path notation in most OOP languages is because they are OOP, and thus don't have free definitions of functions outside of objects. We don't have that problem in REBOL - we can just call functions. |
Steeve 30-Nov-2010 [6401x2] | Pekr, It's strange only because it"s a new paradigm ;-) |
Not that hard to implement to my mind | |
Pekr 30-Nov-2010 [6403] | we are now apparently close to the object redefinition, maybe we could change a semantic, but not sure we want that :-) |
BrianH 30-Nov-2010 [6404] | We don't have to make everything act like OOP languages. If you are looking to other languages for ideas for REBOL, OOP languages are generally a bad choice (says the guy who wrote FUNCT based on ideas from Ruby). |
Pekr 30-Nov-2010 [6405] | ... but then I don't know what Carl has in mind for object spec block |
BrianH 30-Nov-2010 [6406] | The spec is apparently intended to retrofit certain aspects of class-like behavior into objects, such as type specs and (internally) inheritance. Beyond that we don't know, because the discussion stalled due to lack of feedback. |
older newer | first last |