with inner objects i would go with your
 do mold object
it has the additional advantage that it checks your data for moldability.
today its prety reliable, but in the old days a bad string could break it.
when i stored data to disk, i checked them that way, instead of saving broken 
data.
 either attempt[do mold data][save %file data][alert "Internal error"]
So doing it more often may help stability.

-Volker

Am Freitag, 24. Oktober 2003 10:34 schrieb [EMAIL PROTECTED]:
> Gabriele:
> > 1. you can do this:
> >  >> original: context [a: 1 b: 2]
> >  >> template: context [a: b: c: none]
> >  >> probe changed: make template original
>
> Thanks, Gabriele. The one thing I hadn't thought of trying was context --
> the word had slipped from my mental context.
>
> I had to change the code around as context takes a block, not an object --
> hence the the "content third xxx" to grab the block inside the object.
>
> But even then a simple conversion of the code didn't work -- I ended up
> with inner objects still being cloned.
>
> I've had to do a copy/deep of the originals to break the cloning. That's
> almost as unsatisfactory as the original code.  Here's the latest version,
> with a simpler set of test data:
>
> ;;========== the function ==========
> Rebol []
> update-object: func [obj [object!]
>                         template [object!]
>                      /local
>                         obj-copy
>                         template-copy
>
>                  ]
> [
>     obj-copy: make object! copy/deep third obj
>     template-copy: make object! copy/deep third template
>
>  foreach field next first template-copy
>     [
>     ;; add a field if it doesn't exist
>      if  error? try [obj-copy/:field]
>             [
>              obj-copy: context  join third obj-copy
>                      [to-set-word field  template-copy/:field]
>             ]
>     ;; recurse adding fields if field is an object
>     if object? template-copy/:field
>         [
>          obj-copy: context  join  third obj-copy
>                   [to-set-word field update-object obj-copy/:field
> template-copy/:field]
>         ]
>     ] ;; for
>
> return obj-copy     ;; no more do mold !
>
> ] ;; func
>
> ;; ========== Some test data data ==========
>
> original-object: make object! []
> template: make object! [a: make object! [b: 1]]
> new-object1: update-object original-object template
> new-object2: update-object original-object new-object1
>
> print "status messages follow -- all say true if it's worked"
> print not same? new-object1/a template/a
> print not same? new-object1/a new-object2/a
> print equal? mold new-object1 mold new-object2
>
> =============
> Sunanda.


-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.

Reply via email to