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

World: r4wp

[#Red] Red language group

Jerry
23-Mar-2013
[6490]
Beside donation, I would like to contribute to the Red codebase. 
However, the lack of document stops me. I did read Red/System document 
again and again, but it's not enough for me to start. I guess I need 
to read all the red source before I can contribute code? Or is there 
is another way for us to rush in easily and quickly?
DocKimbel
23-Mar-2013
[6491x3]
Depends on what you want to what part you want to contribute?
An internal API documentation would be a good start, but that API 
is not yet fully stabilized...
For now, the best you can do is read all the files in red/runtime/ 
that will give you a good insight on how to add new features.
Kaj
23-Mar-2013
[6494]
Congratulations on the new release. The interpreter is enabling all 
the use cases we know from REBOL
DocKimbel
23-Mar-2013
[6495]
Thanks! This one was tough to get out, so many new features to get 
right and bugs/regressions to fix!
Pekr
24-Mar-2013
[6496]
I can see some lag of Red vs R3, althought not sure it is a fair 
measurement. Just tried with repeat i 1000 ["notning"], and while 
R3 response is instant, Red takes some fair amount of time to complete 
...
DocKimbel
24-Mar-2013
[6497x4]
Have you compiled the console in debug mode? (-d option)
It returns immediatly here with loop counter up to one million.
Close to 3000 hits on red-lang.org since the release, all traffic 
coming from reddit:


http://www.reddit.com/r/programming/comments/1awkcm/red_programming_language_version_032_released/


If you want to help Red, consider posting and upvoting Red there. 
;-)
Creating a reddit account is a 10 seconds procedure and email is 
optional.
Pekr
24-Mar-2013
[6501]
Doc, it was for Try Rebol site, not my own one attempts to test ...
Gregg
24-Mar-2013
[6502]
REPEAT is instant here in the console I just compiled.

Joined Trello. Joined Reddit. I must care. :-)
Kaj
24-Mar-2013
[6503]
Petr, you're looking at network delay
DocKimbel
24-Mar-2013
[6504x2]
Close to 5000 hits on red-lang.org now.
Even if Red is not yet ready for prime time, it is good to have some 
devs having at least heard about it. When we'll launch Red for real, 
that will greatly help it spread around.
Gregg
24-Mar-2013
[6506]
Indeed. That's great Doc.
DocKimbel
24-Mar-2013
[6507x3]
New SYSTEM function added (meant to mimick the SYSTEM object until 
we have object support).

red>> system/version
== "0.3.2, 25-Mar-2013/2:03:45+1:00"
red>> system/platform
== Windows
red>> length? system/words
== 290

So now, who wants to implement WHAT function? ;-)
BTW, we need to add doc-strings to all functions in %boot.red, I 
like the Rebol short but meaningful strings, but I have a few questions 
first:

1) Could we borrow them from R3?

2) Does that fall under Apache license too (I guess so, but just 
checking)?
3) In such case, where and how do we to put proper credits?
BTW, now SYSTEM/PLATFORM replaces previous PLATFORM? function.
Kaj
24-Mar-2013
[6510]
R3 doc strings were released as part of the source, so they are under 
Apache. They would taint Red to fall under the Apache licence, too, 
making it more restricted than BSL and incompatible with GPL
Endo
25-Mar-2013
[6511]
Doc: is it intentional?
red>> repeat i 10 [  ]
== 10
red>> i
== 10
Rebolek
25-Mar-2013
[6512]
AFAIK it is and I really don't like it.
Henrik
25-Mar-2013
[6513]
Can this decision be explained, please?
DocKimbel
25-Mar-2013
[6514x2]
It is intentional and has several purposes: 


a) avoiding the creation of an hidden context for each iterator instance 
and especially the costly deep BINDing of argument block on each 
call.


b) making the iterator word available outside of the loop, can be 
useful when early breaking from loop, avoiding the passing of the 
counter through a BREAK/RETURN. It can also be used to check if the 
loop counter has reached its limit or not.


c) it is IMHO counter-intuitive for users, after a few years you 
get used to it, but it is a wall that every new user will hit more 
than once. I think that the extra step of defining it as local word 
is really not a big deal in comparison. Also, FUNCTION constructor 
could be enhanced to take care of that for you.
I think that my trade-off for Red is "better", but we can discuss 
it if I have missed something.
Endo
25-Mar-2013
[6516x4]
How the outer REPEAT remembers the value i?
red>> repeat i 3 [print i repeat i 2 [print [tab i]]]
1
        1
        2
2
        1
        2
3
        1
        2
And the last value is 2, not 3.
red>> i
== 2
It is a bit confusing.
Even the outer REPEAT doesn't return its last value in this case:
red>> i: repeat i 3 [print i repeat i 2 [print [tab i]] i]
red>> i
== 2

But normally it does:
red>> i: repeat a 5 [4]
== 4
Rebolek
25-Mar-2013
[6520]
I don't want iterator word available outside of loop, this is really 
bad idea.
Endo
25-Mar-2013
[6521]
I *feel* same way, I usually use i, j, k, t, s as /local words to 
functions, and I don't worry to mess them with iterator words inside 
function. But we should explain why or how it is a bad idea to Doc 
(if it really is)
Henrik
25-Mar-2013
[6522]
What does this do (I don't have access to Red here):

repeat i i: 3 [print i]
Endo
25-Mar-2013
[6523]
red>> repeat i i: 3 [print i]
1
2
3
red>> i
== 3
Henrik
25-Mar-2013
[6524x3]
hmm... yes, I guess that makes sense.
but importantly, not necessariy for the same reason as in REBOL.
I guess we need consistency. Do any other loop functions in Red behave 
this way?
DocKimbel
25-Mar-2013
[6527x3]
All behave the same way.
Bad idea

 is not an argument. You should look at it with a fresh view, if we 
 got used to it after several years, it doesn't mean that it was a 
 good design choice in the first place.
How the outer REPEAT remembers the value i?
 Iterator word value is stored on stack, recursively.
Endo
25-Mar-2013
[6530]
Doc: What do you think about the examples above? About return value.
DocKimbel
25-Mar-2013
[6531]
Anyway, you shouldn't use the same word for nested loops, that is 
just confusing and will lead to errors.
Endo
25-Mar-2013
[6532]
But if there is no extra binding, how does this work as expected?
red>> repeat i 3 [print i repeat i 2 [print [tab i]]]
DocKimbel
25-Mar-2013
[6533x2]
Return value: it looks logical to me, REPEAT returns the last value 
from body block. In your example, the last value in the last iteration 
is 2 (because `i` is set to 2 by the inner REPEAT). Same rule as 
for your second code example.
how does this work as expected?

 I just answered that above: "Iterator word value is stored on stack, 
 recursively."
Endo
25-Mar-2013
[6535]
I see. What about FOREACH, it looks it behaves different:
red>> foreach i [1 2 3] [ ]
red>> i
== none
DocKimbel
25-Mar-2013
[6536x2]
That looks like a bug to me.
You should all think about the cost of a), such cost is paid in geometrical 
proportion in case of nested loops. Loops are at the heart of a language 
performances. Implementing it the R2-way (not sure how R3 handles 
it) would kill Red performances.
Henrik
25-Mar-2013
[6538]
If it's a stack, then there would be a small difference in letting 
the word pop, at the end of the loop, which makes it not available 
outside the loop, versus not popping it, leaving it available outside 
the loop, would there not?
DocKimbel
25-Mar-2013
[6539]
It's the word's value that is stored on the stack by REPEAT (or other 
iterators), not the word itself. Words are part of contexts, that 
may or may be not stored on stack. Anyway, you can't add or remove 
a word from a local context in compiled code, at run-time.