I think it depends on if you will be making modification to the passed
structure. For instance, I pass a DSN struct around a lot, but that will
never change. Its only a reference struct, so I don't feel the need to
duplicate it. 

However, if I am passing a struct that may be altered within component, or
method, I would pass in a duplicate (as part of the method call) rather than
duplicate it once I am in the method call. I would say never make the method
worry about validating passed data like that.

.......................
Ben Nadel 
Web Developer
Nylon Technology
6 West 14th Street
New York, NY 10011
212.691.1134
212.691.3477 fax
www.nylontechnology.com

"Vote for Pedro"

-----Original Message-----
From: Andy [mailto:[EMAIL PROTECTED] 
Sent: Thursday, December 01, 2005 2:00 AM
To: CF-Talk
Subject: Structure arguments and Duplicate

When passing structures as arguments and return variables, when should
duplicate be used?  When do I need to be concerned that CF passes pointer to
original versus copy.  For example:
 
Function Foo
    argument fooArg
 
    set var workingFoo = arguments.fooArg
 
    return workingFoo
 
OR
 
Function Foo
    argument fooArg
 
    set var workingFoo = duplicate(arguments.fooArg)
 
    return duplicate(workingFoo)
 
OR duplicate only on original set
OR duplicate only on return
 
And since CF passes pointer versus duplicate, which of these 2 sets is best:
 
    set workingFoo = doSomething(workingFoo)
 
OR just 
 
    doSomething(workingFoo)
 
Since any changes made directly to arguments.workingFoo will also be done to
workingFoo in the calling function....   
 
As you can tell, I am FUBAR'd
 
Andy
   






~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:225812
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to