> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
> Of Barry L Beattie
> Sent: Wednesday, January 19, 2005 9:03 AM
> To: [email protected]
> Subject: Re: [CFCDev] Objects byReference
> 
> 
> >> If you have copied the struct into another variable (inside your
> objects) then the key will remain in the copies
> 
> sure the key will remain as a local copy but that also means it's no
> longer pointing to the origional copy, yes?

I think you may considering things a little off.

There is no "real" copy of a by-reference thing (struct, query, component).
When you do this:

<cfset this.Foo = createObject() />

It creates the object "off in space" - in a special "instantiated object
closet".  "this.Foo" is given a reference to it, it doesn't contain the
"real" object.

Any and ALL references (originals and copies) to anything "by-reference" are
always references, not the objects themselves.

Now when you do:

<cfset this.Faa = this.Foo />

"this.Faa" gets another reference to the object (which is still happily
spending its two-minutes in the closet with all the other instantiated
objects).

Then when you do:

<cfset structDelete(this, "Foo") />

You're just deleting the reference to the object, not the object itself
(which is still in the closet linked by a reference to "this.Faa").

Finally if you do:

<cfset structDelete(this, "Faa") />

The last remaining reference to the object is deleted.  The object is still
in the closet but nothing can access it - there are no more references to
it.  So it's been "orphaned".

Periodically a system process called "Garbage Collection" sweeps through the
closet and deletes any objects with no references.  This is the only real
way to "destroy" an object.

I found this concept very daunting when structs were introduced way back
when...

Jim Davis



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

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

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]

Reply via email to