Check this code (dirty, but functional):

<cfscript>
a = arrayNew(1);
s = structNew();
s.test = "hello";
arrayAppend(a, s);
b = a;
b[1].test = "barney";
writeOutput(a[1].test);
</cfscript>

The output is 'barney', indicating that while the array was copied, only the
pointer to the struct was copied, not the struct itself.  So back to the
original question, you will be allocating more space for your temp array,
but it's only enough space to hold the extra pointers, not duplicated
objects.

barneyb

---
Barney Boisvert, Senior Development Engineer
AudienceCentral (formerly PIER System, Inc.)
[EMAIL PROTECTED]
voice : 360.756.8080 x12
fax   : 360.647.5351

www.audiencecentral.com

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of [EMAIL PROTECTED]
> Sent: Wednesday, June 11, 2003 2:36 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [CFCDev] Array of Objects?
>
>
> 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).
>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.488 / Virus Database: 287 - Release Date: 6/5/2003

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