I don't agree.  If you create a CFC "testComponent" that returns an 
array of the integers 1-100, then run this code:

============================
<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] = "foo">
<cfdump var="#request.thisArray1#">
<cfdump var="#request.thisArray2#">
=================================

request.thisArray2[1] is "foo", while request.thisArray1[1] remains 1.  
Also, the 1000-iteration loop caused my memory monitor to drop 
several K.

Seems like it's creating copies of the array, not pointers at all.  What 
am I missing?

For the self-testers, here's the little CFC I threw together:

========= Begin testComponent.cfc ===========
<cfcomponent displayname="myTest">
  <cffunction name="getArray">
    <cfset myArray = arrayNew(1)>
    <cfloop from="1" to="100" index="i">
      <cfset myArray[i] = "String " & i>
    </cfloop>
    <cfreturn myArray>
  </cffunction>
</cfcomponent>
========= End testComponent.cfc ===========

- Jeff

On 11 Jun 2003 at 15:58, Matt Liotta wrote:

> There aren't really any additional memory requirements since 
> myTempArray is just a reference.
> 
> -Matt
> 
> On Wednesday, June 11, 2003, at 03:27 PM, Jim Mattson wrote:
> 
> > Hello,
> >
> > I have a cffunction that returns an array of objects.  I need to store
> > the array of objects into a temporary variable before I use it.  For
> > example:
> >
> > myObj = createObject("component", "MyComponent");
> >
> > I can not do this:
> > --> ArrayLen(myObj.getArray())
> > or
> > --> myObj.getArray()[1].getInnerObj()
> >
> > I need to change the above syntax to:
> >
> > myTempArray = myObj.getArray();
> > ArrayLen(myTempArray);
> > myTempArray[1].getInnerObj();
> >
> > Isn't CF forcing us to allocate additional memory space by storing the
> > array into a temporary array???  Does anyone know why this is
> > implemented this?
> >
> >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
> > http://calendar.yahoo.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).


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