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

[REBOL] Re: Which? [Object! Block!]

From: al:bri:xtra at: 27-Sep-2001 20:51

Cyphre wrote:
> Your method of adding new value(s) into same object is common but be
careful of cloning objects when the parent object contains another nested object(s)!!! In which case, one needs a 'clone function something like this: [ Rebol [ Name: 'Clone Title: "Clone" File: %Clone.r Home: Author: "Andrew Martin" eMail: [Al--Bri--xtra--co--nz] Date: 27/Sep/2001 Acknowledgements: "Erin A. Thomas" Purpose: { Clone objects by copying objects inside. } Example: [ New_object: Clone Original_Object [] ] ] 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 ] ] ] I hope that helps! Andrew Martin Fingers worked to the bone... ICQ: 26227169