;; ============================== ;; Script: cloneobj.r ;; downloaded from: www.REBOL.org ;; on: 29-Mar-2024 ;; at: 7:04:13.591571 UTC ;; ;; ============================== ;; ================================================== ;; email address(es) have been munged to protect them ;; from spam harvesters. ;; If you were logged on the email addresses would ;; not be munged ;; ================================================== REBOL [ Title: "Object Cloner" Date: 30-Jun-2000 File: %cloneobj.r Author: "Erin A. Thomas" Purpose: { Clone objects recursively. This way the objects inside are copies instead of references. } Email: %timewarp--sirius--com Example: { new-object clone make existing-object [] } library: [ level: 'intermediate platform: none type: 'tool domain: none tested-under: none support: none license: none see-also: none ] ] 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 ]