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

[REBOL] Nested objects

From: gavin::mckenzie::sympatico::ca at: 27-Jun-2001 7:40

Hi, I'm not sure how to do this... 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 ] ] Now, I want all of my inner objects to have a property that ties them to their parent objects. I went looking to see if there was such a built-in property, but the only automatic property of objects appears to be the word 'self'. So, I know that I can easily enough write a routine that walks my tree of nested objects and attempts to wire them together, but I was hoping that there was a way I could get it to happen either: a) automatically b) with a little extra work when I define the objects; something like: obj: make object! [ foo: 1 bar: 2 nested-object: make object! [ parent: obj abc: 3 xyz: 4 ] ] That approach seemed promising, except that it seems that parent doesn't hold a reference to the same 'obj' object, rather it holds a copy. My testing shows that if I change obj/foo to another value, that obj/nested-object/parent/foo hasn't changed value. Any thoughts? Maybe I'm missing something rather straightforward. Regards, Gavin.