r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!REBOL3]

Geomol
17-May-2011
[8712]
Interesting example, you gave with W1 and W2. Funny how recursive 
functions works then!?
BrianH
17-May-2011
[8713]
From Carl, years ago. Set-words in function specs are supposed to 
be used for more in R3 later.
Geomol
17-May-2011
[8714]
Did Carl write about the set-word! in function spec anywhere?
BrianH
17-May-2011
[8715x2]
There is a bug in CLOSURE though. This line:
    insert tail bdy to word! :word

will have problems with some datatypes. I'll fix it for the next 
version.
Set-words in function specs are used by the routine! type now.
Geomol
17-May-2011
[8717]
It's not so good and almost sad, that Carl used so much energy to 
include new stuff (like also routine!) instead of concentrating on 
making the old stuff (from R2) work correctly first.
GrahamC
17-May-2011
[8718]
And now he's burnt out?
BrianH
17-May-2011
[8719]
R2 has routine!, R3 doesn't.
Geomol
17-May-2011
[8720]
I would expect anybody to be burnt out when taking that approach 
to things. It's like building a skyscraper by loosely make all floors 
first, then trying ot fix everything. Better to get first floor solid 
before moving on.
BrianH
17-May-2011
[8721]
Recursive functions in R2 work by pushing the block of values in 
a context onto a stack during the recursive calls, then popping them 
off on return. In R2, function contexts are stack-relative, which 
makes word dereferencing 27% slower relative to object contexts, 
but function calls in general faster. Closures bind to object contexts, 
which are recreated with every function call.
Geomol
17-May-2011
[8722]
R2 has routine! from what version of R2?
BrianH
17-May-2011
[8723]
Any version with library support.
Geomol
17-May-2011
[8724]
:) And when did library support get in?
BrianH
17-May-2011
[8725x2]
I don't know, a little less than 10 years ago?
Whenever /View/Pro or /Command was invented.
Geomol
17-May-2011
[8727x2]
Ok, that's old then.
Does routine! work flawlessly?
BrianH
17-May-2011
[8729]
Don't know. R2's library support was never flexible enough for me 
to be able to use. Others seem to be able to make it work.
Geomol
17-May-2011
[8730x3]
RAMBO holds 15 tickets, when searching for "routine!". 9 are Reviewed, 
6 Built.
Oldest dated 20-Oct-2004, newest 18-Apr-2010.
I would say, we desperately needs a replace for REBOL, so all the 
man-years of work, people have done in creating software with it, 
isn't wasted. It's not all wasted, nomatter what happens, as many 
things work and is used, but many would like to move on, I guess.
BrianH
17-May-2011
[8733x2]
I prefer to think of a combination of R3 and Red as potentially being 
that replacement, but other people may have other plans.
Never mind what I said about the bug in CLOSURE. It's not a bug.
Gabriele
18-May-2011
[8735]
Geomol: syntax is insignificant, translating from one to another 
is easy.


Anyway, the problem with a Scheme using REBOL-like syntax is that 
you give up dialecting (static binding is pretty important for that).
Geomol
19-May-2011
[8736]
I found an bad effect of not binding words in blocks at all, before 
the block is evaluated. Functions like LOOP take 2 args, count and 
block. By not binding the block content before it's evaluated, the 
count arg local to LOOP is found, if a count var is used in the block.

So I guess the REBOL early bind of words is better.
BrianH
19-May-2011
[8737]
LOOP's count arg is not bound to the block of code, so it is not 
local. This is why LOOP is the fastest loop. REPEAT is the version 
of LOOP with a bound local arg.
Geomol
19-May-2011
[8738]
The backside of REBOL's binding is all the unset words, we start 
out with. R2 has 1865 unset words registered in system/words. They 
can be seen with this code:


 foreach w first system/words [if unset? get/any to lit-word! w [prin 
 [w ""]]]
Maxim
20-May-2011
[8739x2]
but doesn't this list disapear with the new multi-level booting of 
R3?  since those words are now not sent in the user context but stay 
in their lower levels?
but its not a big deal... unset words are created just by loading 
any word in a block.  it just means, I've seen this symbol before 
and it now has its reserved number in the word list/hash table. any 
future reference will reuse the same word id (number).
Geomol
20-May-2011
[8741x5]
Yeah, they will be reused. But the way, REBOL do it, if you have 
an application, that do a lot of block parsing for example, with 
new words coming in all the time, then that global context will just 
grow and grow. In reality, it will probably come to an end, as there 
are a finite number of words in a human language, if that's what 
being parsed.


If words were not bound by just being loaded, but only when evaluated 
(or compiled, if that's the case), then parsing blocks would not 
produce any unset! words in the global context. But a consequence 
of this is, that blocks of code being sent to a function (like LOOP), 
will be able to see the words local to that function, unless the 
block is first bound outside the function, like

	count: 1
	loop 10 bind [print count] 'count
, which will then print the number 1 10 times.
I just realized, the global context in R2 and the user context in 
R3 (system/contexts/user) wont grow by this:

to block! "some_random_word"

but it will grow by this:

[some_random_word]
The consequence:

>> count: 1
>> blk: [print]
>> append blk to block! "count"
== [print count]
>> do blk
** Script Error: count word has no context

I wonder, why TO BLOCK! works like this.
Maybe that's the way to have blocks of lots of words, which are just 
data and not bound to anything.
So to not exhaust the global context (if that's a problem), we should 
parse like this:


parse to block! "a few words and then some more" to block! "'a 'few 
'words to end"
Rebolek
20-May-2011
[8746]
AFAIK, to block! doesn't do binding, you have to LOAD the block.
Kaj
20-May-2011
[8747x2]
Yes
John, you seem to want to break down the basic principles REBOL is 
built on
Geomol
20-May-2011
[8749]
I'm trying to figure out the basic principles to understand better, 
what REBOL is. What's good design and what isn't. And what the consequences 
are of different design.
Maxim
20-May-2011
[8750]
john, you are in error when you say: "exhaust the global context" 
 the number of words in the global context is irrelevant to exhausting 
the number of usable words in rebol.

the reason is that binding is not what reserves words in master word 
table.  its anything that creates a new word value, bound or not.

here is an example, using your own to block! example:

>> repeat i 100000 [to-block join "random-word" i]
>> probe length? first system/words
== 2616


pump up the number to 500000 (in 2.7.8) and it crashes.   IIRC this 
was as low as 32k in older versions ! 


with each increment of 100000 you will see the rebol process gobble 
up a few MBs more as it assigns new word-ids to those words.
Kaj
20-May-2011
[8751x2]
Yes, REBOL is symbolic, so there is an internal table of numeric 
IDs for every word it ever encountered in the session
This is an indirection, but different from binding. To abolish that 
table would mean to keep strings everywhere internally instead of 
simple numbers. If you want a language to work that way, you should 
use shell scripting. It's very slow
Maxim
20-May-2011
[8753]
yep
Geomol
20-May-2011
[8754]
I think, there is a third alternative. When we deal with strings, 
a data structure is made, and we just have a pointer to that.

var: "a string"
var: none


When noone is using the string anymore, memory can be completely 
cleaned for it. If I do the same with a word:

var: 'word
var: none


I don't see, why memory can't be cleaned just the same. Is it a design 
flaw, the way it is?
onetom
20-May-2011
[8755x2]
which suggest using some kind of reference counter for the words, 
but what would decrement such a reference counter?
*suggests
Geomol
20-May-2011
[8757]
REBOL use garbage collection, but in the case of counters, the same 
that would decrement a string counter. If a word stop pointing to 
it, decrement. If it's in a block, and the block is destroyed, decrement 
the block content.
BrianH
20-May-2011
[8758]
R3 doesn't have anything like R2's system/user. For all we know symbols 
could be garbage collected. In 32biit R3 though, afaik you will not 
reach the total number of possible words until you have already hit 
the limits of the memory address space first. Does someone have a 
computer with enough RAM to test this? I only have 4 GB.
Andreas
20-May-2011
[8759]
If you write the test, I can certainly run it :)
BrianH
20-May-2011
[8760x2]
for x 0 to-integer #7fffffffffffffff 1 [to-word ajoin ["a" x]]


Then watch the memory usage of the process, and tell us what happens 
and which error is triggered when it fails.
>> to-integer #7fffffffffffffff
== 9223372036854775807

That will be many more words than could be held in memory in a 32bit 
address space.