> -----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 - RUWebby
http://www.ruwebby.com

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:188736
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

Reply via email to