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: 20-Dec-2001 10:37

> -----Original Message----- > From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]On Behalf Of > Romano Paolo Tenca > Sent: Wednesday, December 19, 2001 5:25 PM > To: [rebol-list--rebol--com] > Subject: [REBOL] Re: Objects, references & values > well, i start to understand, here it it is a solution (?) :
Hi, :-)) as non native english speaker it's not so easy to describe a problem that detailed, that the others can follow...
> >> ob: context [name: "romano"] > >> h: append append make hash! [] get in ob 'name in ob 'name > == make hash! ["romano" name] > >> change ob/name "dolores" > == "" > >> h > == make hash! ["dolores" name]
Hmm... what happens if we have several names here? Would this result in: ["dolores" name "romano" name ...] Why the 'name entry? With such a hash! I could search for a name value and get a 'name word that is linked to the address object, right? Would it be possible to use 'self instead of 'name? I used numbers as object index because these don't change if reduced twice.
> The only problem is NOT to change name with an instruction like: > > >>ob/name: "dolores"
;-)) Bingo! We need private data.
> Another solution is writing a custom find which get the value of a word to > search a string. Parse perhaps could help.
I thought about this too. The nice thing about hash! is that (at least that's what I hope) is implemented as a hash datastructure and therefore supports very fast searches. Implementing a custom made find, I might have to iterate over each object... this gives searchspeed O(n).
> I do not think that reduce is well suited, because i think you want to use a > great hash database and reducing it every time is time consuming (reducing > twice more).
I didn't checked this but this could be true. It was just a quick hack to given an example for my not-so-well-described problem ;-))
> The database could be written in Rebol...
I'm a fan of simple solutions and thought that there must be a way to do it with the given parts... anway, after solving the reference problem, I go for this one. Robert