World: r4wp
[!REBOL3] General discussion about REBOL 3
older newer | first last |
BrianH 13-Mar-2013 [1908] | for i 1 2 1 [i: 1] That is changing the index in the body block. That is assumed to be intentional. |
Gregg 13-Mar-2013 [1909] | Brian, agreed, and agreed on accidental infinite loops. |
Ladislav 13-Mar-2013 [1910] | Because that is what we need to make sure *never* happens. - there is only one way how it can *never* happen: if we forget about termination tests and do some arbitrarinesses whatever they are. Count me out |
BrianH 13-Mar-2013 [1911] | I really need to make this clear in the ticket. We need to block accidental infinite loops. We have FOREVER for intentional infinite loops, or the #864 FOR. |
Ladislav 13-Mar-2013 [1912] | Nonsense. There is no such *need* especially when it is making the whole "business" inconsistent |
Gregg 13-Mar-2013 [1913] | For the moment, assuming all Lad's latest tests and design pass, except [1 1 0], as outlined above, are there any other issues Brian? |
Ladislav 13-Mar-2013 [1914] | For example, what is the "consistent" behaviour of: for i 1 1 1 [print i i: -5] (I know what it is having described it in my proposal) |
BrianH 13-Mar-2013 [1915] | It's not arbitrary, it's just not based on termination tests, but based on initial conditions. Once the initial conditions are met it is assumed that any stuff done in the code block is intentional. |
Gregg 13-Mar-2013 [1916x2] | And, Ladislav, *should* [1 1 0] be an intentional, infinite loop in your design? |
It's not clear to me that it should be, since [1 2 0] and [2 1 0] are not. | |
BrianH 13-Mar-2013 [1918] | Termination conditions affect when the loop ends. Initial conditions affect when it starts and which direction it is thought to be going in. |
Ladislav 13-Mar-2013 [1919] | OK, concrete example: for i 1 1 1 [print i i: -5] How and why? |
Gregg 13-Mar-2013 [1920] | And if it should *not* be infinite, is it a "should never start" case, or a "once only" case? |
Ladislav 13-Mar-2013 [1921x2] | Well, I do know what shall happen in for i 1 1 0 [...] depending on the value of i |
(which may have been adjusted in the cycle body) | |
BrianH 13-Mar-2013 [1923] | Once you get past the initial conditions then everything after that is affected by the direction, the bump and the code block. But we have to assume that start, end and bump could have come from the result of a possible erroneous calculation based on crappy data. The initial conditions guard against that. Ladislav, every code example you give that sets the index in the code block is considered intentional behavior. It is only start, end and bump that are considered possible out of the developer's control. If a developer passes an unknown code block to FOR then they deserve what they get. |
Ladislav 13-Mar-2013 [1924] | SImilarly I do know what shall happen in for i 1 1 1 [...] depending on the value of I |
BrianH 13-Mar-2013 [1925] | You are putting your ... in the wrong place. |
Gregg 13-Mar-2013 [1926] | Ladislav, can we address indexing changing scenarios separately? I have to run. Will check back later. If the chat gets long, could someone summarize final thoughts at the end? Thanks. |
BrianH 13-Mar-2013 [1927] | That ... in the body block is the only thing we can safely assume is under the developer's control. |
Ladislav 13-Mar-2013 [1928] | every code example you give that sets the index in the code block is considered intentional behavior. - what behaviour? (I do know what shall happen having specified it, but what shall happen according to your arbitrary rules and why?) |
BrianH 13-Mar-2013 [1929] | My rules aren't arbitrary, as I explained above. Your termination condition rules just don't cover initial condition screening. |
Ladislav 13-Mar-2013 [1930] | Ladislav, can we address indexing changing scenarios separately? - you can do whatever you like being inconsistent however you like. I already addressed all the cases |
BrianH 13-Mar-2013 [1931] | This is a common factor in all of the R3 control functions. The body blocks are considered to be under developer control, while calculated intial conditions are considered to be possibly out of their control. |
Ladislav 13-Mar-2013 [1932] | My rules address any combination of START, END and BUMP with any combination of the actual cycle variable VALUE telling whether the loop shall terminate or not. |
BrianH 13-Mar-2013 [1933x5] | Um, no, because it doesn't handle the problem of making sure that accidental infinite loops aren't screened for. The termination condition that would be affected by bump=0 in your model could also be affected by index changes in the body. Everything in the body is considered intentional. So, you are lumping in presumed-intentional infinite looping with presumed-unintentional infinite looping. It's the same reason why FOREACH [] data body triggers an error, but FOREACH [a:] data body doesn't. |
aren't -> are I hate not being able to edit my posts. | |
For instance, you might noting that FOR has a lit-word parameter for its index. That makes the word peovided considered intentional, because you have to do an extra step to not know which word was provided. And in general, people are presumed to know where they get their code blocks from. | |
So, your CFOR taking 4 code blocks means that people are presumed to control the contents of those blocks. So, infinite loops would be OK in CFOR because it says "General loop" right there in the doc string. | |
In the constrained #1993 FOR, the constraint is a feature. It will protect you from infinite loops that you don't intend, regardless of what start, end and bump say. You would have to go out of your way to make an infinite loop, by setting the index in code that you wrote. That way, you know you can safely call FOR when you don't even know what start, end and bump are. | |
Ladislav 13-Mar-2013 [1938] | In case you have got an arbitrary reason for every design detail you can still enforce your decisions against any other alternative; just don't expect me to not classify it as "crap full of bugs" as I already did for the previous version of FOR |
BrianH 13-Mar-2013 [1939x2] | Well, that difference is a downside to CFOR, but the upsides outweigh it so I prefer #864. |
You are just not used to writing code with bugs in it Ladislav. You don't understand how constraints can be a benefit. | |
Ladislav 13-Mar-2013 [1941] | Nice benefit to know that the best what can be done is to not use the function at all. |
BrianH 13-Mar-2013 [1942x2] | Well, when you're writing infinite loops, yes. It really is better to use FOREVER, it makes your code easier to understand. |
(For normal people I mean, that's not your problem.) | |
Ladislav 13-Mar-2013 [1944] | Also, (just a warning). If you still want to allow cycle variable changes you do need to have the means how to determine when to terminate and when not |
BrianH 13-Mar-2013 [1945] | Right, that is where the termination condititions come into play. The initial conditions just determine which set of termination conditions we want to use. |
Ladislav 13-Mar-2013 [1946] | If you prefer to not have any cycle variable changes, then you are better off having the ability to make your rules consistent somehow |
BrianH 13-Mar-2013 [1947x2] | No, I prefer to allow cycle variable changes in the code block to affect the cycle. The code block is assumed to be under developer control. |
The models I specified only had to do with initial conditions. | |
Ladislav 13-Mar-2013 [1949x3] | Then you are being inconsistent mixing incompatible rules. |
Good luck with that. | |
Well, when you're writing infinite loops, yes - nonsense, the inconsistencies will be observable in finite loops as well | |
BrianH 13-Mar-2013 [1952] | That wasn't a comment on the inconsistencies, that was an answer to the previous message where you said "the best what can be done is to not use the function at all." - I was agreeing with you in the infinite loop case, and giving my reasons why. |
Ladislav 13-Mar-2013 [1953] | But that sill does not solve the case of finite loops, does it? |
BrianH 13-Mar-2013 [1954x3] | We are giving developers more control by saying that some stuff is under their control (i.e. the code blocks). We are providing some safety by saying that some stuff is presumed to be not under their control and thus possibly suspect (i.e. immediate-evaluation parameters to functions that they didn't write). We do screening of some stuff because that cuts down on the screening they have to do themselves. That way dvelopers can use functions and assume that they are safe to use by default. For instance, one advantage of #1993 FOR would be that they would have to go out of their way to make it do an infinite loop, since no combination of start, end and bump would generate one. That means that they wouldn't have to wrap calls to FOR in expensive conditional code, they can just pass in any values of those parameters and trust FOR to never go infinite without them expecting it. Your CFOR would not have that advantage, but since it takes code blocks for all parameters it is assumed that you are more careful about those code blocks, as you should be as a general rule in R3. It's about providing a balance. Complete consistency in how all parameters are treated regardless of their nature would not allow us to help developers where they need it. However, having a consistent policy that code must be treated more carefully by developers than non-code allows developers some flexibility while still allowing them to be careful. That is why code that developers provide explicitly is considered to be what they want to do, at least from the outside of functions. And you can make the distinction between code and non-code using simple type tests, which is why we have APPLY and ASSERT/type. |
But that sill does not solve the case of finite loops, does it? - well, you could have really large finite loops that on a pragmatic level are close enough to infinite to still cause a problem. I think that there is a global evaluation limit that is supposed to protect you from that, but I don't know if that currently works. | |
Of course the evaluation limit is under developer control. | |
Ladislav 13-Mar-2013 [1957] | THat is absoluteyl misunderstanding where the real problem is. |
older newer | first last |