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

[REBOL] Re: Embedded objects.

From: joel:neely:fedex at: 12-Mar-2003 20:51

Hi, Terry, Terry Brownell wrote:
> Sunanda has the solution, but thinking there must be a more graceful > approach? Perhaps not. >
Hmmmm... But Sunanda's explicit proviso points out a severe limitation of this approach.
> -----Original Message----- > From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]] > On Behalf Of [SunandaDH--aol--com] > > Here's one way -- with the usual proviso that it isn't the same Bob > -- we've replaced one with another. ^^^^^^^^^^^^^^^^^^^^^^
> BobsDog: make object! [name: "Rex"] > Bob: make object! [name: "Bob"] > > Bob: make Bob reduce [to-set-word 'BobsDog BobsDog] > > Bob/BobsDog/Name > == "Rex" >
Consider, Bob: make object! [name: "Bob"] Carol: make object! [name: "Carol" husband: Bob] which allows...
>> Carol/husband/name
== "Bob" However, if we now replace Bob with another object to create the new attributea: BobsDog: make object! [name: "Rex"] Bob: make Bob reduce [to-set-word 'BobsDog BobsDog] we can do...
>> Bob/BobsDog/name
== "Rex" But now look at this!
>> Carol/husband/BobsDog
** Script Error: Invalid path value: BobsDog ** Near: Carol/husband/BobsDog
>> mold Carol
== { make object! [ name: "Carol" husband: make object! [ name: "Bob" ] ]} This is the same discussion from a few weeks ago: replacing an object by a different object only updates the reference where the replacement took place; all of the other references to the original object still refer to the original. If you want everybody who knows Bob to know that Bob got a dog, you'll have to do *some* amount of planning ahead. -jn- -- Polonius: ... What do you read, my lord? Hamlet: Words, words, words. _Hamlet_, Act II, Scene 2