I like this method, but why is there not something like this already built it? Like:
<cfset var Blah = ""> <cfreturn Local.Blah> I have always tried to scope things when you can, comes from having to work with other peoples code who never scope a single thing and makes it hard to diagnos. So the idea of being able to set a local variable and not have a scope for it by default is a little foriegn to me though not like we have a scope for a index in a cfloop. Unfortunately my experience with components in CF is rather limited, have done a lot in BD but few in CF so far due to us still using CF5 at work. -- Aaron Rouse http://www.happyhacker.com/ On Fri, 24 Dec 2004 02:31:02 -0500, Jim Davis <[EMAIL PROTECTED]> wrote: > > -----Original Message----- > > From: Michael Dinowitz [mailto:[EMAIL PROTECTED] > > Sent: Thursday, December 23, 2004 2:55 PM > > To: CF-Talk > > Subject: Prefixing local variables > > > > I've started to use a dollar sign as a prefix for variables which are > > local > > to a function or CFC. i.e. those variables created when using the var > > keyword. > > <CFSET var $Localvar=""> > > I could have also used an underscore like so: > > <CFSET var _Localvar=""> > > I plan to give out the new CFCs and functions I'm writing (the logger is > > in > > use and is being tweaked as we speak) and was wondering which you, the > > ColdFusion using world, would prefer. I like the dollar sign, but I'm > > willing to listen to what people have to say. > > Personally, within functions I always declare the following "phony scope": > > <cfset var local = StructNew() /> > > Then all of my local variables are prefixed with "local" as in: > > <cfset local.SomeThing = "" /> > > <cfloop from="1" to="10" index="local.Count"> > > And so forth. > > This way local variables are both clearly defined and not limited to being > instantiated at the top of the function (although it's still a good idea to > do that). > > Jim Davis > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Special thanks to the CF Community Suite Silver Sponsor - CFDynamics http://www.cfdynamics.com Message: http://www.houseoffusion.com/lists.cfm/link=i:4:188750 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

