Nathan, That's good to know, thanks! I was also under the impression that Arrays were "simple" values. Its nice to know they aren't.
-ben ....................... Ben Nadel Web Developer Nylon Technology 6 West 14th Street New York, NY 10011 212.691.1134 212.691.3477 fax www.nylontechnology.com "Vote for Pedro" -----Original Message----- From: Nathan Strutz [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 14, 2005 11:44 AM To: CF-Talk Subject: Re: Are arrays really passed by value? Practice shows otherwise. Sounds like a bug in the documentation, a leftover from the olden days. An array in CF is now a java.util.Vector, definately a complex object! These should be pass-by-reference, aka, sharing a pointer. -nathan strutz http://www.dopefly.com/ On 12/14/05, James Reily <[EMAIL PROTECTED]> wrote: > CF documentation states the following: > > "When you pass a variable to a CFML custom tag as an attribute, > or to a user-defined function as an argument, the following rules > determine whether the custom tag or function receives its own > private copy of the variable or only gets a reference to the > calling page's variable: > > * Simple variables and arrays are passed as copies of the data. > If your argument is an expression that contains multiple simple > variables, the result of the expression evaluation is copied to > the function or tag. > * Structures, queries, and cfobject objects are passed as > references to the object." > > HOWEVER, when I pass an array to a custom tag (.cfm), change its contents in that tag, and then return to the calling tag, the array in the calling tag contains the altered value. Is this a bug? Or is the documentation old and you can now pass arrays by value? > > Example: > > <cfset VARIABLES.array1 = ArrayNew(1)> > <cfset ArrayAppend(VARIABLES.array1, "Original1")> > <cfset ArrayAppend(VARIABLES.array1, "Original2")> > > <cfmodule template="Test.cfm" > SomeArray="#VARIABLES.array1#"> > > <cfoutput>#VARIABLES.array1[1]#> <!--- This shows "ALTERED". Are CF docs wrong?---> > <cfoutput>#VARIABLES.array1[2]#> <!--- This shows "Original2" ---> > > > ---------------------------------------------------------------------------- ---------- > Test.cfm: > ---------------------------------------------------------------------------- ---------- > > <cfset ATTRIBUTES.SomeArray[1] = "ALTERED"> > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:227012 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54