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

[REBOL] Objects, references & values

From: robert::muench::robertmuench::de at: 18-Dec-2001 12:41

Hi, up to now I mostly used Rebol to handle some simple structured data. Now I want to use datastructures to handle more complext data and there I have some problems with. Please keep in mind that I'm an old C++ programmer and might not have switched my mind to see datastructures the rebolized way. Here is my test proggy: Rebol[] myobj!: make object! [ name: string! 0 note: string! 0 ] myobjects1: make hash! [] myobjects2: make hash! [] obj1: make myobj! [name: "Robert" note: "Rebol"] ; this is an obj1 reference insert myobjects1 reduce [1 obj1] ; this is the value obj1/name insert myobjects2 reduce [obj1/name 1] ; this is the value obj1/name value: obj1/name ?? obj1 ?? value ?? myobjects1 ?? myobjects2 ; changing the object obj1 and all of its references obj1/name: "robert" ?? obj1 ?? value ?? myobjects1 ?? myobjects2 halt As you can see, if I reference object-words, I get the value and not the reference to the origianl value. For the C++ developer this means: using obj1 somewhere gives me a pointer using obj1/<some-obj1-member> gives me the value How can I create datsstructures with objects if I can't get references to the original object all the time? I want to have one single object being the base and than use references to the object or parts of it all over my script. Any idea? IMO the concept of a get-path is missing. I would like to write: value: to-get-path obj1/name This should result in a reference to obj1/name and not the value. -- Robert M. Münch IT & Management Freelancer Mobile: +49 (0)177 2452 802 Fax : +49 (0)721 8408 9112 Web : http://www.robertmuench.de