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
[8453]
I'm wanting to send a bunch of huge files to my son. I used this 
command awhile back to convert the files to text, then used compress 
to greatly shrink their size. Unfortunately I accidentally erased 
the source file for my script, and now can't remember the name of 
the command.
Graham
10-Jul-2007
[8454]
compress creates a binary file
Louis
10-Jul-2007
[8455x2]
Graham, sorry for the delay in communucating. The electricity went 
off here, and with it the Internet.
What I want to do in convert a binary file to a string.
Jerry
10-Jul-2007
[8457]
>> blk: [ delete none ]
== [delete none]
>> type? blk/1
== word!
>> type? blk/2
== word!  
;
; none is not of the none! type, unless it's been evaluated. 
; none is so-called indirect value in the REBOL/CORE doc at
; http://www.rebol.com/docs/core23/rebolcore-4.html
;
; In http://www.rebol.net/r3blogs/0034.html, 
; there is a so-called "Scant Evaluation"
;
>> obj: construct [ n: none d: delete ]
>> type? obj/d
== word!
>> type? obj/n
== none! 
; 
; WHY obj/n IS NOT OF THE WORD! TYPE ???
; The "Scant Evaluation" should not evaluate none here.
Louis
10-Jul-2007
[8458]
in headers (and in the construct function) both word lookup and function 
evaluation are disabled, but set-word (assignment) is not.
Jerry
10-Jul-2007
[8459]
Louis, I knew that. My question is ... why none (a word!, not a none!) 
is evaluated in this case. It should not. Notice that none is a word!. 
it has to be evaluated to become a none! That's why Carl called it 
"indirec value" in the REBOL/Core doc.
Louis
10-Jul-2007
[8460x2]
I see what you mean. The actuality seems to contradict those documents.

>> obj: construct [ n: none d: delete ]
>> probe obj
make object! [
    n: none
    d: 'delete
]


It seems that only potentially dangerous evaluation is prevented, 
and not all evaluation.


Scant Evaluation: A minimal form of evaluation used for headers and 
other data blocks that do not allow any level of deep evaluation.
  Perhaps the evaluation of none is not considered "deep."
Pekr, this is what I was looking for (I think): http://www.rebol.net/cookbook/recipes/0048.html


This seems to be related to what you were trying to tell me and I 
just didn't realize it.  Anyway thanks for your help!
Graham
10-Jul-2007
[8462x2]
http://www.rebol.net/cookbook/recipes/0026.html


This recipe says that a binary file is being sent.  I wonder how 
this works because the content type is url encoded, but there is 
not url encode function as a mezzanine by default.
And i don't think that rebol supports octet stream as content type.
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? :-)