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

[REBOL] Re: make/deep functionality?

From: greggirwin:mindspring at: 15-Jan-2003 11:01

Hi Robert, RMM> Why is c changed? And how can I avoid this? I need something like a RMM> make/deep or so. There are a couple CLONE functions out there to do this. Here's a simple one from Erin Thomas in the Script Library: clone: func [ "Clones all sub objects so there are no multiple references" o [object!] "The object to clone" /local wrd so ] [ foreach wrd next first o [ if object? so: get in o :wrd [(set in o :wrd make so []) (clone so)] ] return o ] And Andrew Martin's: Clone: function [ {Clones all sub-objects and hashes, so there are no multiple references.} [catch] Object [object!] "The object to clone." Block [block!] "Extra code for this object." ] [ Cloned Member ] [ throw-on-error [ Cloned: make Object Block foreach Word next first Object [ Member: get in Cloned :Word if same? :Member get in Object :Word [ set in Cloned :Word either object? :Member [ Clone :Member [] ][ either any [ series? :Member port? :Member bitset? :Member ][ copy/deep :Member ][ :Member ] ] ] ] Cloned ] ] -- Gregg