Fair enough.  I had considered the case where variables in your function
might overwrite other variables in the page, but had figured people
should know better to have multiple variables on the same page with the
same name.  Of course, who's to say the UDF couldn't have been written
by a different programmer and cfincluded in a library of other
functions.  Then all of a sudden it would be much easier to get
unintentional overwriting of variables.  Color me convinced.  :)

~Brad

-----Original Message-----
From: Dominic Watson [mailto:[EMAIL PROTECTED] 
Sent: Monday, March 03, 2008 2:24 PM
To: CF-Talk
Subject: Re: CF functions question

No, you absolutely should var that variable, persistant component or UDF
or
whatever and I always var my function and method variables (just lapsed
in
this silly example).

This other silly example demonstrates why (run in a single template):

<cffunction name="foo">
 <cfset i = 100>
 <cfreturn 'bar'>
</cffunction>

<cfoutput>
 <cfset i = 1>
 <cfloop condition="i LT 10">
   <cfset bar = foo()>
   #i#<br />
   <cfset i = i + 1>
 </cfloop>
</cfoutput>
You'd expect the loop to loop 10 times but it doesn't. Var that variable
in
the function and it does.

Dominic

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:300333
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to