[REBOL] Re: Objects, references & values
From: rotenca:telvia:it at: 19-Dec-2001 17:25
Hi Robert,
> Hi, yes you can add it to the hash!, of course. But what do you want to
search
> for in the hash!? You can only search for 'a not the value 'a is refering
to.
> That's my problem. Example:
>
> hash!: ["romano" address-object]
>
> Now I can search for "romano" and get the address-object. In this case I
have to
> update the hash! if your name changes.
>
well, i start to understand, here it it is a solution (?) :
>> 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]
The only problem is NOT to change name with an instruction like:
>>ob/name: "dolores"
because this changes the "fisical memory address" of the string pointed by
ob/name while leaves the old string pointed by our hash series. Another
problem is that this works only with series not with scalars.
Another solution is writing a custom find which get the value of a word to
search a string. Parse perhaps could help.
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).
> > This is true. But load/save are for loading code and related data struct
not
> > for snapshot of data. This seems to me a relational database work.
>
> Yep, but IMO it's unnatural to faltten rebol objects to be stored in an
RDBMS.
> What do you do, if your objects are not all equalle structured? The RDBMS
can't
> handle that. It always needs the table specificaction a priori and complete.
The database could be written in Rebol...
What I want to say is that save/load is not the right method for this kind of
work, it seems to me a more diffcult task, which requires dedicated code. I
think that load/save could be better, they do not save/load neither all the
normal Rebol code (unset problem, series not at head...)
> Robert
---
Ciao
Romano