Hello [EMAIL PROTECTED],

On 19-Jul-00, [EMAIL PROTECTED] wrote:

> [EMAIL PROTECTED] wrote:
> 
>> In REBOL you don't only have two scopes (contexts) - you have a tree of contexts, 
>each one with a parent context, the top level context being what you could call 
>global variables.
> 
> This is probably not true; each context is independent from the
> others.
> 
>> As you can see, contexts are traversed bottom-up to find the value of a word.
> 
> They aren't. BIND simply binds only words that are found in the
> context --- the others are left untouched. The binding is static
> and no lookup is needed at evaluation time.

Well, I guess that's right for 'bind.
BUT if no hieraki is present, how does the following work?

REBOL [
    Title "Test contexts"
]

obja: make object! [
    a: "This is obja's value of 'a"
    b: "This is obja's value of 'b"
    objb: make object! [
        b: "This is objb's value of 'b"
        c: "This is objb's value of 'c"
        objc: make object! [
            c: "This is objc's value of 'c"
            d: "This is objc's value of 'd"
            test-it: func [] [
                print ["words defined in this object! is:" mold first self]
                print ["the value of 'a is:" mold a]
                print ["the value of 'b is:" mold b]
                print ["the value of 'c is:" mold c]
                print ["the value of 'd is:" mold d]
            ]
        ]
    ]
]

obja/objb/objc/test-it

## do %test.r                                                     
words defined in this object! is: [self c d test-it]
the value of 'a is: "This is obja's value of 'a"
the value of 'b is: "This is objb's value of 'b"
the value of 'c is: "This is objc's value of 'c"
the value of 'd is: "This is objc's value of 'd"


-- end of REBOL code --

To accomplice this, I see two posibilities:
a) contexts contain a reference to their parent
b) contexts inherit from their parent

In either way, it _looks_ like a tree :-)

I might be completely wrong, please let me know :-)

>> I hope that future REBOL releases will loosen up on this in some way or another.
> 
> There are some problems in allowing a word to be removed from a
> context. Adding should be feasible, I think.

What kind of problems ?  (I havn't really thought this thru, I mut admit)

> Regards,
>   Gabriele.


Best regards
Thomas Jensen


Reply via email to