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

World: r3wp

[Core] Discuss core issues

Louis
10-Jul-2007
[8464]
Jerry, I found this:


The CONSTRUCT function will perform evaluation on the words TRUE, 
FALSE, NONE, ON, and OFF to produce their expected values. Literal 
words and paths will also be evaluated to produce their respective 
words and paths. For example:


    obj: construct [
        a: true
        b: none
        c: 'word
    ]


The obj/a value would be logical TRUE, obj/b would be NONE, and obj/c 
would be WORD.

file:///C:/SDK/docs/changes.html
Jerry
11-Jul-2007
[8465x5]
Louis, For TRUE, FALSE, NONE, I can understand ( however, it's not 
consistent ). But ... even ON and OFF? Why not YES and NO. ...
>> obj: construct [ a: on b: yes ]
>> probe obj
make object! [
    a: true
    b: 'yes
]
>> yes
== true
>> no
== false
>> on
== true
>> off
== false
Nothing should be evaluated in CONSTRUCT, except SET-WORD!, which 
is an inconsistency.


NONE, TRUE, FALSE, ON, and OFF are not SET-WORD!, but they are evaluated 
in CONSTRUCT, which is another inconsistency in an inconsistency.


YES and NO are not evaluated in CONSTRUCT, which is yet another inconsistency 
in another inconsistency in an inconsistency.

Inconsistency is no good.
I am not trying to be captious. I am trying to write some REBOL 3.0 
tutorial in Chinese. For now, I am working on the evaluation part. 
That's why I am so paranoiac on this. : )
Gabriele
11-Jul-2007
[8470x2]
Jerry, this is a "feature" of construct. the words NONE, TRUE and 
FALSE are converted to the respective values. it is done to allow 
construct to work correctly when /all is not used with mold.
in general, it is much better to use mold/all instead, but i know 
construct can give you headaches if you really want to have a word 
in there.
Rebolek
11-Jul-2007
[8472]
Gabriele so why TRUE and ON are evaluated, while YES is not?
Gabriele
11-Jul-2007
[8473x2]
bug?
actually, i don't think on should be evaluated. mold would never 
produce it.
Gregg
12-Jul-2007
[8475]
I wish there *were* an option to mold it. Sometimes I really want 
to use on/off or yes/no in files.
Henrik
16-Jul-2007
[8476]
my bitset creation skills are a bit rusty. how do I create a bitset 
that means 'anything but #" "' ?
Dockimbel
16-Jul-2007
[8477]
all-but-white-space: complement charset " "
Henrik
16-Jul-2007
[8478]
forgot about charset... thanks
Louis
17-Jul-2007
[8479]
How can I prevent a window from popping up when I have set security 
to none?
BrianH
17-Jul-2007
[8480x2]
Set it on the command line.
rebol -s args
Louis
17-Jul-2007
[8482x7]
Brian, thanks. I forgot to say that this is a script on XP operating 
system. I have the following line in the target field of a shortcut:

C:\.Alkitab\ftp-backup.r -s allow

But the window still pops up.
Hummm, I see that I have it after the script, instead of after rebol.
C:\Program Files\rebol\view\rebol.exe -s allow C:\.Alkitab\ftp-backup.r
 doesn't work either.
C:\Program Files\rebol\view\rebol.exe C:\.Alkitab\ftp-backup.r -s
  doesn't work either.
OK, I copied rebol to the same directory as the script, and now this 
works:

C:\.Alkitab\rebol.exe ftp-backup.r -s
Now, I have just one more problem to solved to be in business. I 
need the script to be run automatically in the background every 10 
minutes, then exit, but windows scheduled tasks can be run no more 
frequently then once a day.
What is the best solution for this problem?
ICarii
17-Jul-2007
[8489x3]
-> Properties -> Advanced -> set to every 10 minutes..
inside the scheduled task..
give it a daily end time and you're away laughing :)
Louis
17-Jul-2007
[8492]
ICarii, thanks. This is my first time to use Schedule Tasks, and 
I didn't go far enough into the wizard to get to the advanced settings.
Pekr
17-Jul-2007
[8493x4]
Does rebol function keeps its local variable (or the whole context) 
in memory, even after finished?
I want my screen to be removed from memory, and am thinking of putting 
the view code inside func as suggested, defining referenced widgets 
as locals ...
however, I am still not sure memory will be freed after function 
call is finished ...
I will continue in View group ....
BrianH
17-Jul-2007
[8497x2]
I think that the memory is not freed in R2, but is in R3.
Use this function for memory cleanup:

after: func [a b] [:a]
Sunanda
17-Jul-2007
[8499]
According to Gabriele, REBOL never frees memory -- ie never hands 
it back to the operating system.

That means (I think) freed / garbage collected memory is kept in 
REBOL's grasp for reallocation, so subsequent allocations are faster 
than ones that need to go to the opsys. But the memory footprint 
of an application can be higher than you'd expect -- especially (say) 
if you do a lot of memory intesmive work at start up: that memory 
will stay allocated to REBOL throughout the life of the application.

One way to avoid that may be to use CALL to run parts of the application 
under another process. Or perhaps use a webserver and split the app 
into several non FastCGI scripts.
***

I've no idea if R3 does allow for opsys memory handback. It would 
be a useful option to have:
    recycle/for-real
Dockimbel
17-Jul-2007
[8500]
From a fresh REBOL/View 1.3.2.3.1 :

>> system/stats
== 4236013
>> system/stats/recycle
== [1 2054 2054 183 183 1869648]
>> make string! 1'860'000
== ""
>> system/stats
== 6099084
>> system/stats/recycle
== [1 2054 2054 183 183 7088]
>> make string! 10'000
== ""
>> system/stats
== 3210049
>> system/stats/recycle
== [2 6385 4331 543 360 2999280]

Just guessing: 


REBOL triggers a GC when the "ballast" value (the last one in the 
block) reaches 0. Then the GC frees only the values that aren't referenced 
anymore. So GC are predictable if you know exactly how much memory 
is consumed by each evaluated expression. Remember that it very easy 
in REBOL to keep hidden references on values (like functions persistent 
context)...


So that way, it keeps a fast average time for new allocations. (I 
guess also that series! and scalar values are managed with different 
rules).


The above example also shows that REBOL gives memory back to the 
OS, but the conditions for that to happen are not very clear to me. 
The GC probably uses complex strategies. If the GC internal rules 
were exposed, we could optimize the memory usage of your applications, 
and probably the speed too.
Pekr
17-Jul-2007
[8501x2]
Does R3 have R2 GC, or new implementation?
BrianH: could you please explain, how your 'after function frees 
memory? :-)
BrianH
17-Jul-2007
[8503]
after: func [a b] [:a]

something: func [/local a] [a: make string! 10'000'000  after a a: 
none]


If you use after a lot, the next call will displace the memory taken 
by the last. If you don't want to wait, call
    after none none
Geomol
17-Jul-2007
[8504x2]
Que? What's the point here?
Is it a way of cleaning up, so the local a doesn't point to some 
mem area, and so the garbage collector can do its job?
BrianH
17-Jul-2007
[8506x2]
Otherwise (in R2) the function SOMETHING will retain the value of 
the word a until the SOMETHING function is called again, or is itself 
collected. If that value is large it could be a problem - hence the 
really large value in my example.
In R3 those words are cleared on function return, so that particular 
problem doesn't arise. There are other kinds of cleanup that AFTER 
can help with though.
Geomol
17-Jul-2007
[8508x4]
I situations with strings (or series in general) like that, I use 
to put the function and the variable in a context and do
clear a

when it's needed. That way I reuse the mem area. Would I need the 
after function? hmm ...
I have never used such technique, but I'll consider it.
To make it clear, I would do something like:

context [
a: ""

something: does [clear a  ... ]     ; do something with a, maybe 
filling it with lots of data or whatever
]
There should of cource be some more code before the end bracket ending 
the context. It was just to illustrate.
Gabriele
17-Jul-2007
[8512]
doc, stats decreases, however size in task manager seems to stay 
the same, so i don't know if memory is actually deallocated or kept. 
maybe the os keeps it for the process.
Dockimbel
17-Jul-2007
[8513]
if you play a little more with this example allocating big buffers 
then releasing them, you'll see memory used going up and down (I 
even could go back close to initial state after something like  a: 
make string! 100'000 recycle). So REBOL releases some parts to OS, 
but it's hard to predict how much and when...