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

[REBOL] Re: Nested objects

From: joel:neely:fedex at: 27-Jun-2001 3:31

Hi, Gavin, Gavin F. McKenzie wrote:
> Say, I've got a bunch of nested objects that I setup > conveniently using syntax like: > > obj: make object! [ > foo: 1 > bar: 2 > nested-object: > make object! [ > abc: 3 > xyz: 4 > ] > ] >
Flo: "Doctor, it hurts when I do this!" Moe: "Well, then don't do that!" Seriously, we had a long thread several weeks back on the topic of "nested objects". This quickly gets into some VERY subtle (IMHO) aspects of REBOL behavior.
> Now, I want all of my inner objects to have a property that > ties them to their parent objects... >
The only way I know how to make sense of the terms "parent object" and "child object" for code like your sample is the issue of which context(s) was/were used to resolve words that were evaluated during the construction of NESTED-OBJECT.
> Maybe I'm missing something rather straightforward. >
Not to my knowledge. Given
>> obj1: make object! [foo: 1 child: none] >> obj2: make obj1 [foo: 2] >> obj3: make object! [baz: 42 parent: none] >> obj1/child: obj3 >> obj2/child: obj3 >> obj3/baz: 17
== 17
>> source obj1
obj1: make object! [ foo: 1 child: make object! [ baz: 17 parent: none ] ]
>> source obj2
obj2: make object! [ foo: 2 child: make object! [ baz: 17 parent: none ] ] I think that tree-walking (or other relationship-management at run time) is the best way to determine whether obj3/parent: obj1 or obj3/parent: obj2 is what you need at any given point. -jn- ------------------------------------------------------------ Programming languages: compact, powerful, simple ... Pick any two! joel'dot'neely'at'fedex'dot'com