World: r3wp
[!REBOL3 Proposals] For discussion of feature proposals
older newer | first last |
Ladislav 11-Nov-2010 [205x5] | Which one is harder? |
At the first sight, none is, I bet, but at the second one: probe reduce dynamic [] 3 probe reduce definitional [] 3 | |
The answer is different | |
So, which one is harder? | |
Btw, for DYNAMIC you will get different answers depending on whether you are running it in R2 or in R3 | |
Maxim 11-Nov-2010 [210] | R3 >> probe reduce dynamic [] 3 ** Script error: i word is not bound to a context ** Where: reduce ** Near: reduce dynamic [i i i i] 3 >> probe reduce definitional [] 3 [3 2 1 0] == [3 2 1 0] |
Ladislav 11-Nov-2010 [211] | So, any favourite? |
Maxim 11-Nov-2010 [212x2] | I'm trying to understand what's going on in R3... |
(in the dynamic version) | |
Ladislav 11-Nov-2010 [214x4] | I could show you a similar example with CATCH/THROW, but it would require more code |
Dynamic variables in R3: they are "not bound to a context" when the function is not running. | |
(that formulation is a bit unfortunate, meaning, that I would not have used it, but, in essence, it means: "don't ask what the value of dynamic variable is, when the function is not running") | |
Nevertheless, you can insert something like if i = 0 [print mold block] to see the result, and compare that to the result in R2 | |
Maxim 11-Nov-2010 [218x2] | wow, I think you've just illustrated a big part of the issue and you should add the above to your exceptions page. |
it does a better job at explaining the underlying issue than the R3 error page IMHO. | |
Ladislav 11-Nov-2010 [220] | The thing just illustrated were "dynamic variables versus definitional variables" |
Maxim 11-Nov-2010 [221] | yes, but the error document tries to illustrate it too, and I didn''t see it as plainly as I do now. |
Ladislav 11-Nov-2010 [222] | need to check that |
Maxim 11-Nov-2010 [223] | I find that the above is a good intruction which makes the "Exception Marker Scoping" more understandable in detail. its not exactly the same, since the error document talks about unwinds, but I feel that the above helps me understand *why* the unwind does what it does. |
BrianH 11-Nov-2010 [224x2] | I really need to fill in the Exceptions page with the real differences and advantages of dynamic and definitional scoping. There are advantages that either has that the other does not. It would be a real loss to not have both in different circumstances. The different circumstances being definitional for returns and dynamic for breaks and throws. |
And anyone who thinks definitional is always better needs to look at #1521. | |
Maxim 11-Nov-2010 [226] | with the above example, I'm thinking about the past discussions and they are starting to make sense in a new light :-) |
BrianH 11-Nov-2010 [227] | I have discussed a new page organization strategy for the Exceptions page with Ladislav. As time permits, I will try to reorganize. It will make these issues much more clear. |
Ladislav 11-Nov-2010 [228] | Max, the errors page you mentioned tried to illustrate the difference between dynamic and definitional return, which looks more subtle, than the difference between dynamic and definitional variables... |
BrianH 11-Nov-2010 [229x2] | its just less complicated to build mezz code with dynamic returns - Depends on the code. Some obscure but important things are impossible if you have dynamic returns. Some less-obscure things aren't even defined as a concept if your returns are definitional.. |
The reason we can get rid of dynamic returns in R3 is because the critical stuff that we used to do with dynamic returns in R2 is *necessarily* handled by dynamic breaks in R3, so dynamic returns are no big loss. | |
Ladislav 11-Nov-2010 [231] | A description of the difference between the definitional and dynamic return: *the dynamic return returns to the dynamically closest function (i.e. to the function that was called as the last one) *the definitional return returns to the definitionally closest function (i.e. to the function that was defined as the last one and contained the return in question) |
BrianH 11-Nov-2010 [232] | That's not all. Definitional also requires the affected functions to have (and in some cases fake) lexical scope. For R3 this means nested blocks. |
Maxim 11-Nov-2010 [233] | lad, what I mean is that the illustration of the variable issues above helps us realize that there even *is* a dynamic vs definitional distinction. it then allows us to more fully understand the return issues. you might be surprised that I never even realized there where dynamic variables, in the way you present it above. Even if I've grown to understand binding pretty deeply. |
Ladislav 11-Nov-2010 [234] | aha, OK |
Maxim 11-Nov-2010 [235] | in a sense... you can say that I might even begin to understand your guru code now ;-) |
Ladislav 11-Nov-2010 [236] | that is you who should say that ;-) |
Maxim 11-Nov-2010 [237] | hehe |
BrianH 11-Nov-2010 [238] | Fortunately, functions are built with nested blocks, though that is partly enhanced in R3 by tasking issues. And while loops are also build with nested blocks, BREAK also applies to PARSE, which relies on dynamic scope (and yes, I can point you to mathematical proofs of this, though there's no point), so we still need dynamic BREAK. Dynamic THROW is just a good idea because of all the capabilities that would give us. |
Ladislav 11-Nov-2010 [239] | but, nevertheless, there isn't any reasonable defnition of dynamic versus definitional concepts in the article, so I take that as a hint |
BrianH 11-Nov-2010 [240x2] | Absolutely right, Ladislav. There needs to be such a definition, or at least a comparison. I was going to add one. |
Not to your page of course :) | |
Ladislav 11-Nov-2010 [242] | Probably an example (or two) is preferable |
BrianH 11-Nov-2010 [243] | This would be part of the issues section, so it would be mostly prose. This is part of a strategy to remove most of the prose from the other sections, so there will be more room for examples. |
Maxim 11-Nov-2010 [244] | btw, the dynamic variable, just solved a long standing binding problem riddle I had with classed based instantiation of objects in R2. when I had talked to Carl about it at the last devcon, even he couldn't explain it... so its a very nice thing to get "out in the open". |
Andreas 11-Nov-2010 [245] | With parse being a dialect on it's own, BREAK in PARSE can be separate from BREAK in loops. So that's not really an argument to keep dynamic BREAK (for loops). |
BrianH 11-Nov-2010 [246x3] | That way the issues can be laid out clearly, so the rest of the page can just link to the appropriate issues sections instead of repeating things. |
PARSE doesn't bind the code in its parens - that's regular REBOL. Parse also can't know ahead of time which blocks it will be treating as rules, because it uses dynamic scope for the whole dialect. | |
Definitional returns or escapes rely on lexical scope. If you don't have lexical scope, you don't have the ability to do definitional. So what PARSE needs is for the top-level BREAK to be dynamic. And if one level is dynamic, we are better off with all levels being dynamic, at least for the same escape function. Same goes for definitional. | |
Andreas 11-Nov-2010 [249] | Thanks for restating the facts. Once again, there's nothing intrinsic in PARSE that forces it to use the same BREAK used in loops. |
BrianH 11-Nov-2010 [250] | Yes there is: Definitional breaks redefine BREAK to a definitional function, and PARSE relies on BREAK being dynamic because PARSE is inherently and necessarily dynamic and doesn't rebind anything in the parens, nor should it. For that matter, PARSE rules can be reassigned in their productions, so PARSE can't even rely on the rules being the same thing the next time round. |
Maxim 11-Nov-2010 [251] | note that there are two usable BREAKs in parse. parse [break] vs parse [(break)] |
Andreas 11-Nov-2010 [252] | Use LEAVE-PARSE instead of BREAK for exiting PARSE. |
BrianH 11-Nov-2010 [253] | Maxim, there is also parse [return]. |
Andreas 11-Nov-2010 [254] | See also the change log notes for A98, where the BREAK handling was actually introduced: http://www.rebol.com/r3/changes.html#section-23 |
older newer | first last |