As a side note to that, have the known issues with the duplicate function been fixed? StructCopy will not work for us as most times we have complex data in those objects.
>I believe simple values are always passed by value. (Boolean, strings,
>etc) Complex values are passed by reference. You'd have to use
>something like StructCopy or Duplicate to make a copy if that's what you
>wanted.
>
>
>
>http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/functa91.htm
>
>
>
>Joe
>
>
>
>-----Original Message-----
>From: Michael Hodgdon [mailto:[EMAIL PROTECTED]
>Sent: Wednesday, September 08, 2004 4:03 PM
>To: CF-Talk
>Subject: Re: reference in cfc
>
>
>
>Hey Jim,
>
>Thanks for getting back to me. Unfortunately it does make sense. I
>really thought (and was hoping) that when you ask a function for some
>data that it returns a copy of that data not a reference to that objects
>data. What is the standard practice for this? How do you truly protect
>an objects data from corruption if when you use a getter on it it
>returns a reference pointer not a copy?
>
>>No. not really.
>>
>>
>>
>>When you "var" a variable you do, indeed, make it private to the
>function.
>>However if you place a reference to a public object in a var'd variable
>it's
>>still a public object.
>>
>>
>>
>>In a sense the var keyword only affects the actual label of the
>variable,
>>not its contents. It does not make clones of its contents or anything
>like
>variable
>>called "foo" completely unconnected with the one in the variables
>scope.
>variable
>>called "foo" completely unconnected with the one in the variables
>scope.
>>HOWEVER the value in this completely unconnected variable is a
>reference to
>>the variables.foo varialble. Changing foo.fiddle in the function
>changes
>and
>>kind
>>of an emergency fo us! Coming up on a deadline fast!
>>
>>It is my understanding that when you "<cfset var var_myvar = "">" (var
>out a
>>
>>variable) you capture information at a function level not at a
>component
>>level.
>>Therefore if I have a data collection in a component that I want to
>grab,
>>analyze, edit, and send to the user without editing the original shared
>
>>component version I can just grab it using the var scope. Once in the
>var
>>scope
>>I can make my edits without affecting the original shared scope
>version.
>>Maybe
>>a description will better explain this:
>>
>>Here is the code I am using to access and modify my component:
>>
>><!--- create and initialize the test object in local memory --->
>><cfset variables.test = createObject("component",
>"cf_components.test")>
>><cfset variables.test.initializeObject()>
>>
>><!--- get and dump the data for this customer --->
>><!--- you should see two keys "firstname" and "lastname" --->
>><cfdump var="#variables.test.getCustData()#">
>>
>><!--- perform a customer analysis, this customer analysis should return
>a
>>structure with a new "description" key in it --->
>><!--- Inside the function I have scooped the component level customer
>>information by using a getter on the original shared data --->
>><!--- Thre returnvariable dumps the data into the var scope. My edits
>>should
>>remain only in that vared out variable --->
>><!--- with the "firstname", "lastname", and "description" field
>contained in
>>
>>var_stCustomerData --->
>><cfdump var="#variables.test.customerAnalysis()#">
>>
>><!--- get the customers original data. This data sits in the shared
>scope
>>of
>>the test object and should not reflect the changes made in
>customerAnalysis
>>to
>>the vared version --->
>><!--- I should only see two keys "firstname" and "lastname" however the
>edit
>>
>>performed in customerAnalysis (on the vared version of the data) edits
>the
>>original information putting description in the shared component
>version
>>--->
>><cfdump var="#variables.test.getCustData()#">
>>
>>Here is my cfc:
>><cfcomponent displayname="test" hint="I am a component that test
>references
>>to
>>stored data.">
>>
>><cffunction name="initializeObject" hint="I prepare the object by
>setting
>not
>
> _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

