[REBOL] Re: Rebol for real world applications
From: rotenca:telvia:it at: 20-Nov-2003 0:54
Hi Sabu,
Memory is auto-recycled.
You can force recycling with the recycle function.
You can test the memory allocated by your program with system/stats
You can have an idea of memory used by some code with these routines:
http://www.rebol.org/cgi-bin/cgiwrap/rebol/search.r?find=mem2
> cfg: make object! [] ; global variable. Is this needed?
No.
> pp: [] ; global variable. Is this needed?
No. Non locals are made globals in Rebol when you load a file.
> loadCfg: function [cfgfile] [kk]
> [
>
> either error? try [ kk: read cfgfile
> pp: to-block kk
> ]
You should use load/all.
To-block works, but it does not load words in the global context.
Un-loaded words are buggy in Rebol and can lead to crashes.
> [ return false ]
> [
> cfg: make object! pp
> clear pp;
> return true
> ]
>
> ]
your function can become:
loadCfg: func [cfgfile][
not error? try [
cfg: make object! load/all cfgfile
]
]
>> loadcfg "a: 2"
== true
>> probe cfg
make object! [
a: 2
]
You should know that make object! executes the body block (the loaded block),
so it is not secure.
---
Ciao
Romano