[REBOL] Embedded Object and Scope - again...
From: coussement:c:itc:mil:be at: 9-May-2001 10:53
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==