Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Embedded object and scope

From: coussement::c::itc::mil::be at: 7-May-2001 14:01

Hi list: 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==