[REBOL] A collection of garbage
From: patrick::philipot::laposte::net at: 8-Jul-2003 13:46
Hi List
I often code functions returning a block.
What happens to all these blocks?
Are they "garbage collected"? I doubt it ...
Imagine a code like this one:
gimme: func[n][b: copy [] for i 1 n 1 [append b i] b]
print gimme 5
print gimme 15
print gimme 10
As I see it, there are 3 blocks that will stay in memory forever.
And this slightly different version seems not better:
gimme: func[n /local b][b: copy [] for i 1 n 1 [append b i] b]
The best I can think of is to provide a block to the function:
gimme: func[n b [block!]][clear b for i 1 n 1 [append b i] b]
result: copy []
print gimme 5 result
print gimme 15 result
print gimme 10 result
Any inspired comments?
Regards
Patrick
Regards
Patrick