World: r4wp
[!REBOL3] General discussion about REBOL 3
older newer | first last |
BrianH 13-Mar-2013 [1937] | 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 [1957x2] | THat is absoluteyl misunderstanding where the real problem is. |
OK, nevermind. I will try to be understandable for you: if you want to do so, you *can* eliminate the only combination of START, END, BUMP values that causes infinite loop by default while still remaining consistent at the cost of disallowing something that may be perceived as "legitimate" by some users, and as an "unsolicited for" limitation. | |
BrianH 13-Mar-2013 [1959] | Really? Because I was assuming that FOR would have termination conditions (similar to yours). The initial conditions model just picks which set of termination conditions to apply, at least as far as the start, end and bump parameters are concerned. The body parameter, being a code block, is assumed to be under developer control. So if the developer wants to hack the termination conditions in the code block that is their fault. |
Ladislav 13-Mar-2013 [1960] | Ha, are we still discussing 1993 or some other ticket? |
BrianH 13-Mar-2013 [1961] | FOREVER is assumed to be a solicited-for infinite loop, because it's right there in the name. #864 is assumed to be whatever the developer says, because "General loop" is right there in the doc string. #1993-1994 FOR has the *feature* of not *accidentally* being infinite for any value of start, end and bump, its constraint is a feature; of course it could be *intentionally* infinite by changing the index in the code block, but that just means that there is one parameter that the developer would have to be careful about, the body block, and since that is a general pattern throughout R3 they would be doing that anyway. |
Ladislav 13-Mar-2013 [1962x2] | Assuming that we are discussing #1993 and assuming: * you insiste to allow the FOR I 1 1 0 and similar to be "infinite by default" * want to support cycle variable changes in a simple and consistent way the best you can do is to cause an error when finding out that all [start = end bump = 0] is TRUE, since in that case there is no reasonable terminating condition that could not cause infinite loop by default. Some people may object, but otherwise it looks as not a big deal. |
err: "you insist to not allow FOR I 1 1 0 and similar to be "infinite by default"" is what I meant | |
BrianH 13-Mar-2013 [1964x7] | {you insiste to allow the FOR I 1 1 0 and similar to be "infinite by default"} -> {you insiste to allow the FOR I 1 1 0 and similar to never be "infinite by default"} |
Right. | |
The fact that we even have a FOREVER loop at all means that there would be a value in having developers use it, just for their own documentation. | |
And that allows developers to be less careful with start, end and bump, for values of "careful" that mean "wrapping FOR in expensive conditional code". | |
We've been trying to reduce the amount of expensive conditional code throughout R3. That's why a lot more functions allow none now. | |
ASSERT/type means that typechecks don't have to be considered expensive anymore. Value checks still require EITHER and other conditional functions though. | |
For that matter, typesets make the type tests of function argument specs less expensive now too, so we can afford to be picky there as well. | |
Ladislav 13-Mar-2013 [1971] | Am I to understand that instead of causing an error int that case you simply prefer to not loop taking it as an exceptional condition? |
BrianH 13-Mar-2013 [1972x2] | An out-of-range condition, yes. |
The other model was the trigger-an-error model. | |
Bo 13-Mar-2013 [1974] | BrianH: I'm really glad to hear that there is a concerted effort to reduce the amount of expensive conditional code throughout R3. Great job all! |
Ladislav 13-Mar-2013 [1975] | Hmm, it is not out-of-range in the normal sense, because when START = END and BUMP = 0 the values both are and remain "in range", but it is "exceptional" |
BrianH 13-Mar-2013 [1976x4] | Depends on the model. If bump is a velocity, you can say that only velocities above (or below of you're going in reverse) 0 are in range. |
That is a matter of coming up with a plausible theoretical explanation for something that we want to do for practical reasons. | |
Then start-vs-end sets the direction, and bump sets the velocity. It's just a way to explain *why* to newbiees. | |
Dealing with the consequences of triggering an error is more expensive, so we tend to only want to trigger errors when they really *are* errors. If there is a plausible way to just do nothing and/or return none when it's not potentially damaging, we should come up with a rationale that lets do that instead. | |
Ladislav 13-Mar-2013 [1980] | You can say that you "support" zero velocity by "not looping", but, in fact, you rather don't support it by failing as silently as possible. |
BrianH 13-Mar-2013 [1981] | It's really a rationale. |
Ladislav 13-Mar-2013 [1982x2] | No problem to say it is "zero velocity". The problem is that in "normal life" something having zero velocity does not "vanish", rather it stays where it is. |
So you may be caught as using "inappropriate logic", but I do not mind, being able to eventually answer that it is an exceptional case that you simply did not want to handle to not cause headaches to some users, while causing inconveniences to people being able to calculate what it is they should have expected. | |
BrianH 13-Mar-2013 [1984] | We can just arbitrarily declare that we want 0 velocity to be considered out of range, as a favor to the developer, and the velocity explanation gives us a good excuse to not trigger an error. FOREVER existing means that they have other options, and index setting means that they can do whatever they want if they really want to, so it's not actually a constraint if they don't want it to be. |
Ladislav 13-Mar-2013 [1985] | You can always declare something arbitrarily. The problem is that if you do declare a + b = none in case a = 0 you are most probably causing inconveniences to all people knowing that there might have been a more consistent behaviour... |
BrianH 13-Mar-2013 [1986] | Remember, #864 is a proposal to replace FOR with a more flexible power-user function that would be less safe to use. They lose some safety as a tradeoff for more power and prettier sytnax. So, they lose two features (safety and backwards compatibility) but gain more flexibility. The greater flexibility would come at the expense of a slower function: negligably in the case of the function itself, but more when you add the conditional wrapper code, so it would have to be used carefully if you want it to be efficient. Overall, that is the R3 motto right there: R2 is for newbies, R3 for power users. |
older newer | first last |