I really don't know the answer.
I think we need a make/deep or something.
I think the embedded-object words are still bound to
the ancestor-object context. That means global-obj-prop
is still bound to the ancestor-object.
Does this modification help?:
print-global-obj-prop: func [obj][
print get in obj 'global-obj-prop
]
; try it out
ancestor-object/init 10 ; == 10
ancestor-object/embedded-object/print-global-obj-prop
ancestor-object ; == 10 - good
;try it out again
descendant-object/init 20 ; == 20
descendant-object/embedded-object/print-global-obj-prop
descendant-object ; == 20
Anton.
> Hi list:
>
> ----------------------------------------------------
> Sorry for insisting, but it's the first time one of my question stays
> unanswered, and I need the answer badly ;-P
> I still hope somebody will help me (perhaps at RT) so I repost my
> question...
> ----------------------------------------------------
>
> I tried the following:
>
> <snip>
>
> ancestor-object: make object! [
>
> global-obj-prop: make integer! 0
>
> init: func [
> val [integer!]
> ][
> global-obj-prop: make integer! val
> ]
>
> embedded-object: make object! [
> print-global-obj-prop: does [print global-obj-prop]
> ]
> ]
>
> </snip>
>
> Ok, so I tried:
>
> >> ancestor-object/init 10
> == 10
> >> ancestor-object/embedded-object/print-global-obj-prop
> 10
>
> No problem here :-)
>
> >> descendant-object: make ancestor-object []
> >> descendant-object/init 20
> == 20
> >> descendant-object/embedded-object/print-global-obj-prop
> 10
>
> Ouch, not what I thought... Let's check... In the "Official
> Guide", pg 348,
> I found:
>
> <quote>
> "The ancestor object and the descendant object share the same embedded
> object."
> </quote>
>
> OK, so I tried something else:
>
> >> descendant-object: make ancestor-object
> [descendant-embedded-object: make
> embedded-object []]
> >> descendant-object/init 20
> == 20
> >> descendant-object/descendant-embedded-object/print-global-obj-prop
> 10
>
> Again, not what I thought ... I was awaiting 20 !!! ;-(
>
> Here are my questions:
>
> 1. Why did RT choose for such implementation ? What are the advantages ?
> 2. Why did my last try not work - it was -IMHO- logical I should get a
> result of 20 ..., as I instanciated the embedded object within the
> instanciation of the ancestor object.
> 2. How can I get my descendant-embedded-object to retrieve the property of
> it's container, the descendant-object ?
>
> Thx for answering :-))
>
> chr==
--
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the
subject, without the quotes.