• Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r4wp

[!REBOL3] General discussion about REBOL 3

MarcS
13-Mar-2013
[1879x2]
Regarding http://curecode.org/rebol3/ticket.rsp?id=1974, https://github.com/0branch/r3/commit/7b4e8529e683c92d406e89b287092507c5876924
Perhaps I should have mentioned truncation explicitly in that commit 
msg.
Gregg
13-Mar-2013
[1881]
Posted %mezz/new-loop.r for comment. Not complete, but should be 
enough to use for discussion, pro or con.
sqlab
13-Mar-2013
[1882]
I think the proposed loop is too mighty.

How easily do you forget an argument without getting an error and 
doing something different to what you wanted.
Ladislav
13-Mar-2013
[1883x3]
I'm happy with FOR as I do not need to construct and perhaps REDUCE 
a block to set up variable start conditions 

 - this looks like you never used CFOR, otherwise you would have know 
 that it does not require anything of that kind
For me, the syntaxtic sugar neatness of the new proposals is outweighed 
by the simplicity of the setup for the existing method.

 - funny, again, the simplicity of the setup of CFOR is mentioned 
 while not taking into account that:


* there are requirements FOR can never meet already handled by CFOR
* the simplicity of CFOR setup was not even checked
https://groups.google.com/forum/#!msg/Rebol/appT3TV5urY/rQ1XJLwZXFwJ
Gregg
13-Mar-2013
[1886]
Sqlab (I'm sorry I don't remember your real name, and it's not in 
your profile here), it would certainly be easy to add keywords as 
markers, even optionally; or remove the REPEAT compatible option 
if that's too liberal. With the latter change, the only difference 
from FOR is that the bump value is optional.
MarcS
13-Mar-2013
[1887]
Pull request addressing CC #1974, https://github.com/rebol/r3/pull/104
Gregg
13-Mar-2013
[1888]
Ladislav, in your latest FOR notes, is your last case [for i 1 1 
0] an infinite loop? I changed %new-loop.r to reflect your design, 
but tripped over that and wanted to clarify. Is this a correct interpretation?

Normal termination
    [loop [i 1 2 1]  [print i]]
    [loop [i 2 1 -1] [print i]]

Should not start
    [loop [i 2 1 1]  [print i]]
    [loop [i 1 2 -1] [print i]]
    [loop [i 1 2 0]  [print i]]
    [loop [i 2 1 0]  [print i]]

One cycle
    [loop [i 1 1 1]  [print i]]
    [loop [i 1 1 -1] [print i]]

Infinite loop
    loop [i 1 1 0]  [print i]
Ladislav
13-Mar-2013
[1889x3]
Ladislav, in your latest FOR notes, is your last case [for i 1 1 
0] an infinite loop?

 - hmm, I cannot tell for sure allowing the changes of the cycle variable. 
 However, if no change occurs, it is expected to be
The case

    for i 1 1 0 [print i]

certainly is
I appreciate your effort trying to understand what I wrote. I am 
not the best author of easily readable texts, usually preferring 
unambiguity, exactlness or other qualities.
Gregg
13-Mar-2013
[1892x3]
The examples are great. It was just this one case, which I think 
differs from Brian's model.
That is, should FOR sometimes go infinite.
In any case, I can post my update for evaluation.
BrianH
13-Mar-2013
[1895]
One thing that we need to make sure of is that the #1993 FOR should 
never ever result in an infinite loop if the loop variable isn't 
modified in the code block. That should never be an option.
Gregg
13-Mar-2013
[1896x2]
OK, then we need to clarify that final case.
I just posted my changes, but the last case does result in an infintie 
loop.
BrianH
13-Mar-2013
[1898x2]
I was very specific about that in the initial choice of models. Any 
model which allowed any value of bump to result in an infinite loop 
needs to be excluded from out choices.
I need to be more clear about that in the ticket and comments.
Ladislav
13-Mar-2013
[1900]
It was just this one case, which I think differs from Brian's model.

 - that is not true, in fact. Brian stated arbitrary rules like "for 
 i 1 1 whatever [...] should loop exactly once", that is a difference 
 as well
BrianH
13-Mar-2013
[1901]
OK, so the difference between your model and one of my two models 
is that it allows something that we absolutely need to forbid? Or 
am I misunderstanding your model?
Ladislav
13-Mar-2013
[1902x3]
Having any termination test that can happen only if there is:


a) no adjustment of the cycle variable in the body changing this 
"expectation"

b) the bump is 0, which, of course, cannot change the termination 
test result when the variable remanins unadjusted
Brian, your arbitrary rules don't make sense when observed from the 
"termination test" POV. There is no termination test that can yield 
TRUE and FALSE being run twice in a row and not having changed inputs
Examples:

for i 1 1 1 [i: 0]

shall loop infinitely
BrianH
13-Mar-2013
[1905]
OK, so the important question which you are glossing over by going 
on about termination tests is: Can any combination of start, end 
and bump result in an infinite loop without changing the index explicitly 
in the body block? Because that is what we need to make sure *never* 
happens.
Ladislav
13-Mar-2013
[1906]
for i 1 2 1 [i: 1]

shall loop infinitely as well
BrianH
13-Mar-2013
[1907x2]
The whole point is to avoid accidental infinite loops.
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?)