Hi!

As some of you may know, all the script I wrote since last July
required indefinite extent to work for contexts created with 'use.
Since tha bug in the garbage collector still has to be fixed, I
decided to write a workaround, and finally had the time to do so.

The function :hide creates a new context by creating an object;
this way I can put a reference to that object somewere, so that
the gc will not free it. The disadvantage is, it will never be
freed this way...

I'm attaching hide.r here. I made a new version of using.r too, if
someone is interested. When I'll find them to be stable, I'll
upload to rebol.org too.

Awaiting for comments, :-)
    Gabriele.
-- 
o--------------------) .-^-. (----------------------------------o
| Gabriele Santilli / /_/_\_\ \ Amiga Group Italia --- L'Aquila |
| GIESSE on IRC     \ \-\_/-/ /  http://www.amyresource.it/AGI/ |
o--------------------) `-v-' (----------------------------------o
REBOL [
        Title: "Local words with indefinite extent"
        Author: "Gabriele Santilli"
        File: %hide.r
        Date: 7-Nov-1999
        Version: 0.0.1.2 ; release.status.majorv.minorv
                                         ; status: 0: alpha; 1: beta; 2: gamma
        History: [
                 7-Nov-1999 0.0.1.1 "First version"
                 7-Nov-1999 0.0.1.2 "Little bugfix"
        ]
]

hidden-contexts: make object! [
        notice: "Please leave this object alone. You have been warned. :-)"
        create-object: func [
                "PRIVATE"
                words [block!]
                /local result
        ] [
                result: make block! 1 + length? words
                foreach word words [
                        if word? word [insert tail result to-set-word word]
                ]
                insert tail result none
                make object! result
        ]
]

hide: func [
        "Make words local to the block, but with indefinite extent"
        words [block!] "Local words"
        block [block!] "Block of code"
        /local result
] [
        hidden-contexts: make hidden-contexts compose [
                set/any 'result do bind block in
                        (to-set-word to-string reduce [random 100 '. now]) 
                        create-object words 'self
        ]
        get/any 'result
]

Reply via email to