While discussing this with a collegue, I had a couple of added
insights.

Joel Neely wrote:
> 
...
> As to why the same logic isn't propagated upward through
> multiple layers of enclosing objects, I can only speculate
> that RT:
> 
> 1)  simply didn't think of it
> 2)  thought of it but didn't want to incur the expense,
>     assuming that it wasn't as compelling a situation, or
> 3)  implemented the context mechanism in a way that made
>     it infeasible to chase up a list of "nested contexts".
> 

That may sound harsher than I meant -- I wasn't criticizing,
but just trying (poorly) to say that what one can do easily
with one mechanism may or may not be easy or obvious or even
useful if one has a different conceptual mechanism.

I should also have added another option:

4)  the entire concept of "embedded object" isn't really
    meaningful to REBOL.

Consider this transcript:

    >> obja: make object! [
    [    a: 1
    [    b: "hi"
    [    f: func [] [print a]
    [    ]
    >> objb: make object! [
    [    c: 10
    [    d: "there"
    [    x: obja
    [    g: func [][print [x/b d c + x/a]]
    [    ]
    >> objb/g
    hi there 11
    >> objc: make objb [c: 20 d: "you guys"]
    >> objc/g
    hi you guys 21
    >> obja/a: 100
    == 100
    >> objb/g
    hi there 110
    >> objc/g
    hi you guys 120
    >> source objc
    objc:
    make object! [
        c: 20
        d: "you guys"
        x:
        make object! [
            a: 100
            b: "hi"
            f: func [][print a]
        ]
        g: func [][print [x/b d c + x/a]]
    ]

Now, let't think about these questions:

1) In what sense do OBJB and OBJC "contain" OBJA?
2) In this case, don't we want OBJB and OBJC to "share"
   a single OBJA (even though we don't retain its
   global name)?
3) How is this different from either of the cases below?

CASE 1: "EMBEDDED" OBJECT

    >> obje: make object! [
    [    c: 20
    [    d: "yawl"
    [    x: make object! [
    [        a: 2
    [        b: "greetings"
    [        f: func [] [print a]
    [        ]
    [    g: func [][print [x/b d c + x/a]]
    [    ]
    >> obje/g
    greetings yawl 22
    >> objf: make obje [c: 30]
    >> objf/g
    greetings yawl 32

CASE2: "PRIVATE" OBJECT

    >> use [secretobj] [
    [    secretobj: make object! [
    [        a: 3
    [        b: "howdy"
    [        f: func [] [print a]
    [        ]
    [    objg: make object! [
    [        c: 30
    [        d: "youse guys"
    [        x: secretobj
    [        g: func [][print [x/b d c + x/a]]
    [        ]
    [    ]
    >> objg/g
    howdy youse guys 33
    >> objh: make objg [a: 40 d: "aloha"]
    >> objh/g
    howdy aloha 33

The fact that an object is created concurrently with an
"enclosing" object is time-wise coincidental, except when
the "inner" object contains words that refer to members
of the "outer" object without explicit qualification.

> >
> > 2. How can I get my descendant-embedded-object to retrieve
> > the property of it's container, the descendant-object ?
> >
> 
> I can think of a couple of ways to get this effect.
> 
> 1)  Construct a new object in a way that strips off context
> for all words.
> 

Of course this fails if you *DO* want some sharing -- if you
want the new object simply to refer to a third party also
referenced within the old object.

-jn-
-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to