OK, here goes and yes it is to do with pointers/references AFAIK.

----
>> temp = StructNew();
This creates a new empty structure named Temp

>> <cfset newtemp = temp>
This creates a new variable names "newtemp" which is a pointer to the
original structure

>> <cfset temp.value = "Hello">
This creates a new key named "value" within the original structure and
places the word "hello" into it, notice you are now refencing it from the
pointer.

>><cfset temp = 45>
This is actually creating a simple variable within the variables scope and
assigning "45" to it.

Personally, I think the above is not very good as it leads to confusion on
variable names and can lead to deep reviewing of code which can take time.

You can gain more insight into whats happening by using CFDUMP on either
"temp" or "newtemp" and you will see that one is a simple variable and one
is a struct.

HTH, though I am sure one of the other guru's may be able to give you a more
in-depth expanation  as this could be way off the mark, as I said.....I hate
references and deep copies.... 

Neil



-----Original Message-----
From: Tangorre, Michael [mailto:[EMAIL PROTECTED]]
Sent: 06 February 2003 13:41
To: CF-Talk
Subject: Copying Structure? Reference/Value


can someone help me to understand the following:

<cfscript>

temp = StructNew();

</cfscript>

<cfset newtemp = temp>

<cfset temp.value = "Hello">

<cfset temp = 45>

<cfoutput>

#newtemp.value# #temp#

</cfoutput>

according to some cfmx exam study questions, the output would read "Hello
45" (without the quotes).

I assume this has to do with the way copying variables and references and
the like..

any clarification would be great.

Thanks,

Michael T. Tangorre



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to