Wild, it looks like it's going to custom tags by reference, but UDFs
by value.  Here's a test I wrote:

<!--- Index.cfm --->
<cfset myArray = arrayNew(1) />
<cfset myArray[1] = "unchanged" />

<cffunction name="arrayTest" returntype="array">
        <cfargument name="array" type="array" required="true" />
        
        <cfset arguments.array[1] = "changed" />
        
        <cfreturn arguments.array />
</cffunction>

<cfset newArray = arrayTest(myArray) />

<cfoutput>
If arrays went to UDFs by reference, this would read "changed":
#myArray[1]#
<br />
</cfoutput>

<cfmodule template="module.cfm" array="#myArray#" />

<cfoutput>
If arrays went to modules/tags by reference, this would read "changed":
#myArray[1]#
</cfoutput>

<!--- Module.cfm --->
<cfif thistag.executionmode eq "start">
 <cfset attributes.array[1] = "changed" />
</cfif>


-Joe

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">
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:227014
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=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to