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

[REBOL] Re: Objects, references & values

From: robert:muench:robertmuench at: 19-Dec-2001 13:55

> -----Original Message----- > From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]On Behalf Of > Romano Paolo Tenca > Sent: Tuesday, December 18, 2001 7:41 PM > To: [rebol-list--rebol--com] > Subject: [REBOL] Re: Objects, references & values > nameref: in obj1 'name > > Now 'nameref is a pointer to a word which is linked to the field called "name" > in the object 'obj1.
Hi, yeah that's right but how do you search for the value of nameref? With this you can't use the hash! datatype because you don't have a value hash! can use. That's why I would like to have a value which I can add to a hash! that's updated when the referenced value changes. I know that's not easy to achieve. Even with C++ and the STL container you have the same problem. You can either use the pointer address to your value as hash-key, or you can use the value as hash-key. What to do if a key-value changes? Well, search it, remove it and add the new key-value. The problem to solve is that you have to be sure to keep everything in sync. In C++ you can do this by using member-functions and makeing the data-members private to the object. This ensures that none will be accessed/changed directly without executing the house-keeping code.
> Another method: > x: bind [name] in obj1 'self > > Now x is a block which contains as the first item the word 'name linked to the > object obj1: > > x: bind [name] in obj1 'self > == [name] > >> get first x > == "robert4"
Ok. BTW: I just had an idea. When using 'bind you can't see from the word, to which it is bound. Howabout having "bind [name] in obj1 'self" return obj1/name? This would be very logical IMO. As said, the biggest problem I currently have is that I would like to have a simple way to use the well known datastructures for managing objects, values etc. and being able to search, store etc. those datastructures. BTW: What happens if those structures are stored? Will Rebol be able to resolve the linking again? I don't think so... this implies that a datastructure loader is needed to setup all those references again. Robert