For those that are interested, here's another test:

I changed the previous CFC to return an array of structures, with each 
member of the array defined as a reference to the same structure.

When called, the returned arrays behave as expected:  Each array 
member contains pointers to the same structure, but each array has 
its own structure created (separate calls to the CFC method).

Here's the code:
============ Start testComponent.cfc ==============
<cfcomponent displayname="myTest">
  <cffunction name="getArray">
          <cfset myStruct = structNew()>
                <cfscript>
                  myStruct.first = "John";
                        myStruct.last = "Public";
                </cfscript>
    <cfset myArray = arrayNew(1)>
    <cfloop from="1" to="4" index="i">
      <cfset myArray[i] = myStruct>
    </cfloop>
    <cfreturn myArray>
  </cffunction>
</cfcomponent>
============ End testComponent.cfc ==============

And the test:

============ start tst_testComponent.cfm ===========
<cfscript>
 myObj = createObject("component", "test.testComponent");
</cfscript>

<cfloop from="1" to="2" index="j">
  <cfset "request.thisArray#j#" = myObj.getArray()>
</cfloop>

<cfset request.thisArray2[1].first = "foo">
<cfdump var="#request.thisArray1#">
<cfdump var="#request.thisArray2#">
============ start tst_testComponent.cfm ===========

What this does to help solve the original question, I have no idea, but 
maybe it'll help somebody... ;)

- Jeff

On 11 Jun 2003 at 17:36, [EMAIL PROTECTED] wrote:

From:                   [EMAIL PROTECTED]
To:                     [EMAIL PROTECTED]
Date sent:              Wed, 11 Jun 2003 17:36:04 -0400
Subject:                RE: [CFCDev] Array of Objects?
Priority:               normal
Send reply to:          [EMAIL PROTECTED]

> Hm.  This begs for more testing.  For example, what happens if you pass an array of 
> structures?  Is each structure then passed by value because it's contained in an 
> array, 
> or are they still passed by reference?
> 
> - Jeff
> 
> On 11 Jun 2003 at 17:16, Dave Watts wrote:
> 
> From:                 Dave Watts <[EMAIL PROTECTED]>
> To:                   "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
> Subject:              RE: [CFCDev] Array of Objects?
> Date sent:            Wed, 11 Jun 2003 17:16:49 -0400
> Send reply to:        [EMAIL PROTECTED]
> 
> > > I believe that since CF now is just Java, the Java rules 
> > > apply, so only primitives are copied by value.
> > 
> > No, arrays are passed by value still. Queries, structures, and XML document
> > objects are passed by reference.
> > 
> > Dave Watts, CTO, Fig Leaf Software
> > http://www.figleaf.com/
> > voice: (202) 797-5496
> > fax: (202) 797-5444
> > 
> > ----------------------------------------------------------
> > You are subscribed to cfcdev. To unsubscribe, send an email
> > to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
> > in the message of the email.
> > 
> > CFCDev is run by CFCZone (www.cfczone.org) and supported
> > by Mindtool, Corporation (www.mindtool.com).
> 
> 
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
> in the message of the email.
> 
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

Reply via email to