Some time ago while working in cfscript I had the need to cfparam a bunch of variables. I was building an XML document out of form fields and a number of the fields wouldn't always exist. At first I made a simple UDF to encapsulate a cfparam tag, but it this code was inside of a loop that beat it over and over again before it was finished and performance just wasn't cutting it. The culprit as it seemed was scope hunting.Before I go too far, I would like to point out there have been many long-winded discussions about performance, what code runs better on what version of CF, and what a proper load test is etc. That is really neither here nor there. I am simply documenting how I solved my problem. I changed the function to use isdefined() and first, but then still unhappy with the apparent scope hunting and ambiguity I switched to using structkeyexists() and structinsert() and I called the function structparam(). The idea was to be able to set the default value AND get the value out at the same time. I believe the reason I had so much better performance out of it was because in my specific scenario a majority of my variables were most likely NOT to exist. Since I pass the scope/struct into the function I believe that effectively eliminated the need for CF to search all the scopes. This was what I came up with.
[code]<cfscript>

/**
 * Function to duplicate the <cfparam> tag within CFSCRIPT.
 *  I attempted to make cfparam faster by eliminating
 * the evaluate, and using structkeyexists
 * According to my tests this is MULTUPLE times faster
 * than the cfparam tag when the variables
 * being paramed are more likley NOT to exist.
 *
 * @param struct 	 The struct. 
 * @param key 	 The name of the key
 * @param default_value	The default value. If not passed, use  
 * @return Returns the value of the variable parammed. 
 * @author Brad Wood 
 * @version 1, November 16, 2006 
 */
function structparam(struct,key,default_value) {

	if(not structkeyexists(struct,key))
		{
			structinsert(struct,key,default_value);
			return default_value;
		}
	else
		{
			return structfind(struct,key);
		}
}

</cfscript>
[/code]
Usage was as follows:
[code]<cfscript>

foo = structparam(attributes,'bar','default value');

</cfscript>[/code]
I really wish ColdFusion's structinsert() function did NOT an throw an error when "allow overwrite" is set to no and the key exists. Then it would be the perfect replacement for a cfscript param.