[EMAIL PROTECTED] wrote:
> That is understood. I'm talking about how long that staticly contexted 'f
> will remain accessible. My expectation is that as long as some live
> reference to 'f continues to haunt REBOL, 'f should stay alive as well. Of
> course, the value 'f references will be determined by the value last passed
> to the function, in whose context the argument 'f is defined.
>
> Opinions?
I agree.
>> g: func [x] ['x]
>> a: g 4
== x
>> get a
== 4
>> recycle
>> get a
== 4
>> b: g 6
== x
>> get b
== 6
>> get a
== 6
So I was not surprised seeing Ladislav's results. If one uses a
dynamic context, things are different:
>> g: func [x] [use [y] [y: :x 'y]]
>> a: g 4
== y
>> b: g 5
== y
>> get a
== 4
>> get b
== 5
But:
>> recycle
>> get b
***CRASH***
A workaround:
>> hidden-contexts: make list! 0
== make list! []
>> g: func [x] [insert tail hidden-contexts make object! [y: :x (x: 'y)] x]
>> a: g 4
== y
>> b: g 5
== y
>> get a
== 4
>> get b
== 5
>> recycle
>> get b
== 5
>> get a
== 4
Ciao,
/Gabriele./
o--------------------) .-^-. (----------------------------------o
| Gabriele Santilli / /_/_\_\ \ Amiga Group Italia --- L'Aquila |
| GIESSE on IRC \ \-\_/-/ / http://www.amyresource.it/AGI/ |
o--------------------) `-v-' (----------------------------------o