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

World: r4wp

[!REBOL3] General discussion about REBOL 3

Bo
12-Mar-2013
[1809]
Maxim: Right now, I would use something like the following:

x: 1
endval: length? b
until [
	either s1/:x = b [
		do something
		x: x + 1
	][
		do something2
		x: x + 5
	]
	x >= endval
]
Henrik
12-Mar-2013
[1810x2]
MarcS, I cannot replicate that on OSX with build fc51038.
I don't see it in the experimental 64 bit build either.
MarcS
12-Mar-2013
[1812]
Henrik: thanks for the info.
Henrik
12-Mar-2013
[1813]
BTW, this is on 10.8.
MarcS
12-Mar-2013
[1814]
Here too
DocKimbel
12-Mar-2013
[1815]
Bo: you could rely on FORALL and series positions instead of carrying 
numerical indexes around:

forall b [
    offset: either b/1 = pick s1 index? b [
        do something
        1
    ][
        do something2
        5
    ]
    b: skip b offset
]
MarcS
12-Mar-2013
[1816]
Sunanda mentions that 1.1.1 / .1 is correct under R2/Windows. Can't 
test that currently, but 9.9.9 is returned by R2/Linux (i.e., this 
behaviour doesn't look like a regression in R3)..
Gregg
12-Mar-2013
[1817]
Marc: R2/Win correct here. R3/Win incorrect here.
MarcS
12-Mar-2013
[1818]
I have a provisional fix in place for R3/Linux.
Gregg
12-Mar-2013
[1819x2]
Bo, while I want flexibility as well, especially in a language like 
REBOL, I don't think we need complete flexibility everywhere. Constraints 
are very powerful and helpful.
To me, FOR creates an expectation of consistent stepping behavior, 
*but* there are times when you don't want that, and FOR seems like 
the first function you still want to go do.
BrianH
12-Mar-2013
[1821]
Ticket for the FOR stepping behavior: http://issue.cc/r3/1993. The 
FOR index modification behavior will be a separate ticket, since 
while they'll likely need to be implemented at the same time, they 
need to be discussed separately.
Gregg
12-Mar-2013
[1822]
Thanks Brian.
Sunanda
12-Mar-2013
[1823]
Is this by design or oversight? DATE can be used for most access 
paths, but not with PICK
    ser: [1-jan-2000 9999]
    select ser 1-jan-2000
    == 9999
    find ser 1-jan-2000
    == [1-Jan-2000 9999]

    ser/1-jan-2000
    == 9999
    pick ser 1-jan-2000
    ** Script error: invalid argument: 1-Jan-2000
Gregg
12-Mar-2013
[1824x2]
I would say it's by design.
That is, what position would it reference?
BrianH
12-Mar-2013
[1826x2]
It would make sense for maps, where SELECT and PICK are pretty much 
the same thing, but not for series, where they mean something different.
PICK for series just means the index, or something that can be translated 
into an index like logic is.
Ladislav
12-Mar-2013
[1828x6]
We should allow one iteration when start = end, but trigger an error 
otherwise if we have a non-advancing step.

 - I am asking to make sure I understand this formulation. Does it 
 mean that you want to allow

    for i 1 1 step [...]

in case step <> 0 but not in case step = 0?
For start > end, if step is positive then FOR should do nothing. 
It should only trigger an error for 0. 
 - hmm, I find it quite natural to prefer:


For start > end, if step is not negative then FOR should do nothing
 like Endo seems to prefer
The reason is that it is simpler.
 even though general loops are more expensive to use in interpreted 
 languages

 - that may be true in general, but, funnily enough, my general loop 
 implementation was always faster in R2 than FOR
Actually, there is one more reason I see why a general loop is quite 
natural and it is needed in Rebol: in case we need to iterate using 
decimal! values, it is quite likely that we need more "custom" END 
comparisons than any FOR implementation can give us. That is exactly 
the case when FOR cannot be improved much.
'However, "I want to skip x values ahead" does sound like an argument 
for allowing index changes to affect the looping process, as a power-user 
feature.' - agreed, it may be convenient when the user needs such 
a feature
Bo
12-Mar-2013
[1834]
Gregg: I'm all for constraints if there is a significant "win" component. 
 If it doesn't, don't constrain it.  Apple, but especially Microsoft, 
are really good at artificially constraining software.  Frustrates 
me to death.  Most of the time, it just seems like a poor design 
decision.  Other times, I can see how the constraint is being used 
to generate revenue.
Ladislav
12-Mar-2013
[1835]
However, I am quite unsure whether Carl implemented it as a "power 
user feature" or if he had some other reason (looks likely to me)
BrianH
12-Mar-2013
[1836]
For some reason I thought that R2 allowed indexes to be changes, 
but R3 didn't, and that was a loss of functionality. After actually 
testing, it appears it was the other way around, a gain of functionality. 
I'm for R3's model in this case, enough so that I didn't think it 
worth adding a ticket.
Bo
12-Mar-2013
[1837]
If this was a language designed to promote "proper" programming, 
I could see having constraints on every function to keep them from 
being used in new ways, and to promote the proper usage of the function. 
 However, in real life, flexibility is key.


Let me know if this makes any sense:  If I want to rip the fender 
off my car and fashion it into a medieval helmet, physics allows 
me to do so (if I had the requisite skill).  However, in programming 
languages, this type of thing would rarely be possible.


So what I'm saying is this: Try as much as possible to refrain from 
placing software developers in a box when it comes to how they might 
choose to use a function or a feature.
BrianH
12-Mar-2013
[1838]
Bo, we're agreeing with you in this case. Stop arguing before you 
convinve us otherwise! :)
Gregg
12-Mar-2013
[1839]
There is nothing preventing you from hacking FOR into a helmet. What 
I'm saying is that we should tell developers "Here is a helmet, and 
here is a fender. You should use each appropriately." and we shouldn't 
make the fender a poorer fender design in order to accommodate helmet 
makers.
Ladislav
12-Mar-2013
[1840]
Try as much as possible to refrain from placing software developers 
in a box when it comes to how they might choose to use a function 
or a feature.
 - yes, makes sense to me, Bo. I alway try to achieve that
Bo
12-Mar-2013
[1841]
BrianH: Thanks. Sometimes I end up "preaching to the choir."


Gregg: I wasn't proposing to compromise the intended functionality 
of a function.  I was simply stating that *artificial* constraints 
shouldn't be placed on a function for the purpose of limiting its 
functionality.
Gregg
12-Mar-2013
[1842]
Agreed Bo. Constraints should exist only to empower us.
BrianH
12-Mar-2013
[1843]
Ladislav, in answer to your first question about "We should allow 
one iteration when start = end, but trigger an error otherwise if 
we have a non-advancing step.", yes. That is the difference between 
the two models in that ticket. 0 bump should behave consistently, 
according to a model which makes sense.


In one of those models, the bump is given primacy over the start-vs-end 
factor, and judged *on its own* a bump of 0 is an error (since it 
doesn't make FOR advance in one or the other direction). So, that 
error should be triggered categorically before the range is even 
considered.


If, on the other hand, start-vs-end is given primacy, then we have 
3 valid answers to the direction argument: forwards, backwards, or 
once - the bump argument doesn't determine direction, it determines 
velocity in the direction already chosen. In the start=end case the 
bump is always ignored, so ignoring it for 0 makes sense. In the 
start<end or start>end cases, a bump of 0 is basically out of range 
because those cases are only defined  to move in the positive or 
negative direction, respectively. That means that start<end is only 
positive, and start>end is only negative.


Does that make the difference between the models clear? Of course, 
because you can BREAK, CONTINUE, or even set the index position in 
the code, that doesn't actually reduce our flexibility where we really 
want to do anything interesting. It just makes the basic model make 
sense.
Ladislav
12-Mar-2013
[1844x2]
For me, the model preferring START and END to determine the direction 
makes more sense and looks less constraining.
The model preferring BUMP looks rather "uninteligent" and "constraining" 
to me.
BrianH
12-Mar-2013
[1846]
Agreed. I mostly put that in for contrast.
Ladislav
12-Mar-2013
[1847]
I understand that you put the "if START = END" rule there to have 
the definition simple enough but not simpler than useful
BrianH
12-Mar-2013
[1848]
Well, if you think bump should have primacy, triggering an error 
for 0 before you even look at start or end is the only thing that 
makes sense. And the velocity model for bump is the only justification 
for its existence at all if start-vs-end has primacy. Really, it 
can be anything we want as long as it makes sense :)
Ladislav
12-Mar-2013
[1849]
However, I must agree with Fork that we need a general loop in Rebol 
no matter what. (see e.g. iteration in the decimal range as an example) 
Just the dialect he proposed does not look sensible to me when compared 
to the general loop I am using for a long time.)
BrianH
12-Mar-2013
[1850]
I think that something as powerful as yours, but maybe a little friendlier 
for the newbies, and maybe with some REWORD-style thoroughness, might 
work. I think that we need to go beyond the old style of general 
loop though - we're competing against languages with list comprehensions, 
not just C-like languages :)
Ladislav
12-Mar-2013
[1851x2]
But CFOR can do list comprehensions easily, I do not see any problem 
with that
http://issue.cc/r3/884
BrianH
12-Mar-2013
[1853x2]
So it's not a power thing. Cool.
It's a dialect thing then.
Ladislav
12-Mar-2013
[1855x2]
power

 only in the sense that you get the power to specify looping in an 
 easy and flexible way
However, it is easy to see that it is not too slow compared to other 
looping constructs
BrianH
12-Mar-2013
[1857]
Not easy and flexible enough. You proved that we can do this already 
with the two-line implementation, but it doesn't have the syntactic 
sugar that the list comprehension fans need. So we might want to 
rethink the API but keep the power. Sometimes I think you're too 
smart for dialect design, Ladislav :)
Ladislav
12-Mar-2013
[1858]
Sorry, the "not easy and flexible enough" does not make much sense 
to me. There is no more flexible cycle function than this one in 
Rebol at present.