World: r3wp
[!REBOL3]
older newer | first last |
Steeve 25-Mar-2010 [1882] | Amen |
BrianH 25-Mar-2010 [1883] | Ah, but in R2 those contexts were broken when they extended beyond the life of the function that created them. The first field was treated like 'self, and hidden. |
Steeve 25-Mar-2010 [1884] | I like reading the scriptures. The Gospel according to St. Ladislav. |
BrianH 25-Mar-2010 [1885x5] | And the programmer that matters when it comes to BIND is the one that is calling BIND, and providing the code block. Not the one that made the context. It's different with internal use of BIND, functions that make, use and discard a context. If the context persists then it needs to behave in a predictable matter. R2 is not a good example to cite when deciding what is good coding practices; we made the decision to change things in R3 for *many* good reasons. |
If the context persists then it needs to behave in a predictable matter. - and I mean predictable by someone who didn't make the context in the first place. | |
Otherwise we won't be able to write generic code that works with all contexts. | |
And once again, I regret that we decided to use the term "context" so badly here in the REBOL community. It's really inappropriate. | |
It's much better to call them objects; the Lisp community calls them environments. | |
Ladislav 25-Mar-2010 [1890x3] | And the programmer that matters when it comes to BIND is the one that is calling BIND, and providing the code block. Not the one that made the context. - this is interesting, again. My note is, that if the context was created to support e.g. the functionality of For, then any subsequent binding is meaningful for me, only if the functionality remains supported. I think this way, even when I am the one calling Bind and providing the block, unfortunately, I may not know, which alternative mentioned by you to use, not knowing the type of the context I obtained. As opposed to that, when I see a context without 'self, I know, that the context was created so, that it is not meant to support 'self binding, and that is all I need to know. How would you do it obtaining a context of unknown origin, that would contain '"unsolicited" self? (of course, not knowing that information, since there is no way how you can find that out) |
I meant the above as a contribution to the "predictability" issue - how can you predict, whether the block would behave as originally intended, not knowing, what the original intent was? | |
(unfortunately, the same objection applies to #1544, since then, again, "the original intent" is lost) | |
BrianH 25-Mar-2010 [1893x2] | Generic functions that work on objects don't see the code that originated them. They can only tell how the objects are supposed to behave with their own code. Original intent was contextual (using the term correctly this time). Current behavior is a different context. |
It's like that quote from The Incredibles: "I know what I said before! Listen to what I'm saying *now*." | |
Ladislav 25-Mar-2010 [1895] | I provided above a specific example, that demonstratd clearly what I meant. The support for code like that is missing in R3 and remains missing, even if any of #1544 or #1543 will be accepted. |
BrianH 25-Mar-2010 [1896x3] | What you want is for objects created by loops and functions for their local variables, but persisting after their creators are finished with them, to *break* all other code that expects objects to behave like objects. Same as in R2. It was a bad idea in R2 (which we can't fix) and it's a bad idea in R3. |
This is what we get for calling objects "contexts": It makes us think they are contextual, when they aren't. | |
If you don't like the hidden 'self field in objects in R3, fine, but it was a fix to major problems in R2. Problems we don't want to come back. | |
Ladislav 25-Mar-2010 [1899x2] | ...to *break* all other code that expects objects to behave like objects... - this has been demonstrated by Andreas to be false - I do not want to break any behaviour of objects, I do want to not break behaviour of other contexts than objects |
...and, besides, my code example above is not of the kind "after their creators are finished with them" | |
BrianH 25-Mar-2010 [1901] | Only the function! type creates other "contexts" than objects: It creates a stack-relative objects. All other contexts *are* objects, internally. Even those used by closures and loop functions. There is no difference. |
Ladislav 25-Mar-2010 [1902] | yes, harm already done, the closure, For, Use, Repeat, Foreach, etc. contexts already broken |
BrianH 25-Mar-2010 [1903] | They were broken in R2. Problem solved for R3 - we just have to manage the binding trick. |
Ladislav 25-Mar-2010 [1904] | as demonstrated by my code, already broken, my code works in R2 |
BrianH 25-Mar-2010 [1905x2] | Oh, and module and script contexts are objects too (internally in the case of modules). |
Your code does what you want it to in R2. That is not the same thing as not being broken. | |
Ladislav 25-Mar-2010 [1907] | OK, I say it differently: the functionality demonstrated by my code is not broken in R2. The functionality demonstrated by my code is broken in R3. |
BrianH 25-Mar-2010 [1908x2] | Your car has a broken axle that makes it go left. "Oh, don't worry, I only want to go left anyways." |
There should have been a :) in there somewhere I guess. | |
Ladislav 25-Mar-2010 [1910] | OK, playing with you: "my car has a broken axle that makes it go left, therefore, I can easily demonstrate, that the functional ability of my car to go left is not broken". how can I call a car, that does not have this functionality, i.e. it cannot go left?" - I call it broken |
BrianH 25-Mar-2010 [1911] | Sorry, i meant "go left only in a 20ft radius circle", I didn't mean something most people would want to do when they aren't showing off. |
Andreas 25-Mar-2010 [1912] | Once again, this issue could easily overcome by having to separate types |
BrianH 25-Mar-2010 [1913] | Imagine that your DO-IN-CONTEXT function was written by someone else, to take any object, and depended on the 'self override. That is the most common case for functions that operate on objects they did not create and use 'self. Those would be broken if there is no 'self . |
Andreas 25-Mar-2010 [1914] | If you want an context! to behave like an object!, convert the former to the latter |
Ladislav 25-Mar-2010 [1915] | yes, that is very reasonable for me, as a clean solution |
BrianH 25-Mar-2010 [1916] | Andreas, agreed, the problem could be solved by having two types. But that's unnecessary, since we have a solution already that doesn't require another type. And the two-type solution wouldn't help with loops and closures unless BIND? returned an object type from words bound to the non-object type, because to do otherwise would break BIND. |
Andreas 25-Mar-2010 [1917] | Why would that break bind? |
BrianH 25-Mar-2010 [1918] | Because even if we made BIND not do the 'self trick by default, we would still *need* to add the /self option, and that option would *need* to have a 'self field to do the trick with, *every time*. |
Ladislav 25-Mar-2010 [1919] | , and, the solution you mention is broken, without any hope that all the bugs will be cured, the more tricks you implement, the deeper you descend into the trouble |
Andreas 25-Mar-2010 [1920] | While I'm not even sure that we would still need /self, I can't see where the problem is. BIND/self simply won't work on context!s |
BrianH 25-Mar-2010 [1921x2] | Because otherwise every code block we are binding with BIND/self would leak references to whatever binding 'self had already. |
You have to assume that the 'self trick needs to be able to work with every "context" that you pass to BIND, even if BIND doesn't do the trick by default. Because the trick is necessary for a lot of code. And leaked 'self references can be a security hole, allowing access to otherwise encapsulated code. | |
Ladislav 25-Mar-2010 [1923] | like the DO-IN-CONTEXT function - actually, I assumed, that there are two programmers: one implementing the other function, and the other implementing te DO-IN-CONTEXT function. Their functions will cooperate only if no tricks are played |
BrianH 25-Mar-2010 [1924x3] | Ah, but you were also assuming that BIND doesn't do or depend on the 'self trick. Try the function with BIND/self. |
Make sure that DO-IN-CONTEXT uses BIND/self, depends on it, requires it. Then pass in a "context" created by a loop function. | |
It's all well and good to say that the current BIND does the 'self trick and you don't like that. But there is a lot of code that depends on that trick, so if you don't want to do it for your code, you better make that an option (perhaps the default one). | |
Andreas 25-Mar-2010 [1927] | that code is scripts, modules, objects? |
BrianH 25-Mar-2010 [1928] | there is a lot of code that depends on that trick - Not R2 code of course. R2 breaks code that depends on 'self existing. |
Andreas 25-Mar-2010 [1929] | Where is the problem in doing bind/self for object! contexts and bind/no-self for context! contexts? |
BrianH 25-Mar-2010 [1930x2] | Andreas, yes, those. TO-MODULE would break utterly, for instance, no recovery possible, if BIND accepted contexts that didn't have 'self. |
There is no problem with not doing the 'self trick if you don't want to. The problem would be if you *can't* do the 'self trick with any indefinite-extent context that exists, and you would run into that problem if it was possible to make an indefinite-extent context without the special 'self field. | |
older newer | first last |