Correct. That's what pass-by-reference means. There is only ever a single instance of the "thing" in question, and when you assign it to another variable, you're just making a new reference to the same object. Pass-by-value, on the other hand, creates a new copy of the "thing" across assignments, and the two instances are completely unrelated.
Primitive types are almost always pass-by-value, while complex types are almost always pass-by-reference. The notable exception is CF arrays, which are pass-by-value (for some unknown reason). Note, however, that the pass-by-value is a shallow copy, not a deep copy, so if you have pass-by-reference types in an array, the array is duplicated but the objects inside are not. <cfset a = arrayNew(1) /> <cfset s = structNew() /> <cfset s.name = "barney" /> <cfset arrayAppend(a, s) /> <cfset s.name = "heather" /> <cfset arrayAppend(a, s) /> <cfdump var="#a#" /> <cfset a2 = a /> <cfset s = structNew() /> <cfset s.name = "ryan" /> <cfset arrayAppend(a, s) /> <cfdump var="#a#" /> <cfdump var="#a2#" /> That code will illustrate all three concepts (array pass-by-value, struct pass-by-reference, and shallow copy of arrays). Make sure you manually figure out what you expect it to do before running it. cheers, barneyb On 9/26/05, Ryan Guill <[EMAIL PROTECTED]> wrote: > Okay, so taking this a step further, If I take a component and create > an object out of it, stored in varible x, set variable y equal to > variable x, change a value in variable x, the value in y should have > changed as well? > -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 100 invites. ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). CFCDev is supported by New Atlanta, makers of BlueDragon http://www.newatlanta.com/products/bluedragon/index.cfm An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
