Dave, as you well know I usually agree with you.  However, in this case, I
do not agree with you at all.  Why?  Because you are 100% wrong in your
statement.  What I showed is **exactly** how references work.

1) If you create a _reference_ to something as my code example did...

<cfset session.myvariable = form />

2) and then you change the original...

<cflocation url="foo.cfm" />

3) the reference **will** be updated to match the value to which it is
pointing at.

In ColdFusion, structures are passed _by reference_ rather than _by value_.
The only way to pass a structure in CF by reference is by using
duplicate().  Can it be an expensive operation?  Ayep.  Is it necessary when
you want to pass by value rather than reference?  Ayep.

The 'form' scope, like all others in CF, is a structure.  Therefore the
rules about reference and value apply to it just as though you had created
the structure yourself with structNew().

Test the code I wrote.  You'll see that I am right.

Now then, if you are setting your session values like so...

<cfscript>
    session.myvariable = {};
    for ( key IN form )
    {
         session.myvariable[key] = form[key];
    }
</cfscript>

... then you are creating brand new variables that will are _value_ based
rather than simply a reference to the form scope.  If this is what you are
doing, then, of course, changing the form scope (of form-scoped variables)
will have no bearing on the session variables you created.

HTH


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:342174
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to