> >Worth reiterating that you can't call arguments unless you explicitly >specify the arguments scope. Any implicit references to the >argument scope >are actually references to the local variables scope. Thus you can >introduce nasty bugs: > ><cffunction name="factorial"> > <cfargument name="num" /> > <cfset var i = "" /> > <cfloop from="2" to="#arguments.num - 1#" index="i"> > <cfset arguments.num = arguments.num * i /> > </cfloop> > <cfreturn num /> ></cffunction> > >What's that function do? If you said computes a factorial, >you'd be wrong, >it actually returns the same number. Note that it does NOT >create a 'num' >variable in the 'variables' scope. That kind of potential >nastiness is why >I never scope argument references, prefering to always use the >local copy >(which can't be scoped).
I think we're in agreement here. I essentially treat the arguments scope the same as the cgi scope. It's there to pass information to you, not for you to manipulate. If you ever want to go back and find out what was originally passed in to a function then you can use the arguments scope for simple variables. For variables that are passed by reference, such as structures and component instances, I believe that the copy in the function local scope is just a reference to the same data as is in the arugments scope, but I've never really tested that thoroughly. I've just erred on the side of caution and assumed that was the case. Spike ---------------------------------------------------------- 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]
