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

[REBOL] copy with object words and values

From: greggirwin::starband::net at: 13-Sep-2001 13:36

Ingo Hohmann wrote a couple nifty functions for retrieving the words and values from an object. In his routines, he uses copy when returning the data. ; Ingo Hohmann values-of: func [ "Returns block of object word values next to self directive" object[object!] "Object words of which its values should be returned" ][ copy next second object ] Q. Should I even bother worrying about efficiency? Should I just use copy, as Ingo does, to be on the safe side or can I safely return the data without using copy? I played around a bit and it doesn't appear that the object data is at risk of modification, via the result, even without copy. I'm very likely missing something though. Q. If there is a difference, and I add a /copy refinement to the routine, is there a way to "inline" copy so I don't have to have two separate blocks that are identical except for the copy call? ; Gregg Irwin values-of: func [ "Returns block of object word values next to self directive" object[object!] "Object words of which its values should be returned" /copy "Use the copy refinement if you want a copy of the data" ][ either copy [copy next second object][next second object] ] Thanks! --Gregg