I've been using that exact makeup in my CFC's for a while and have had no
problem. Well only one, making sure that each and every variable declared is
part of the local struct.

Still its a lot easier to declare everything like that then var"ing" every
variable. 


Sandra Clark
==============================
http://www.shayna.com
Training in Cascading Style Sheets and Accessibility 
-----Original Message-----
From: Ian Buzer [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 21, 2006 10:11 AM
To: CF-Talk
Subject: Local function variables in CFC

Hi everyone,

I find myself getting more and more wound up that variables set within a cfc
function are not scoped to that function but to the entire cfc.

I'm ending up with a whole series of <cfset var myVariable = ""> at the
beginning of the function which is messy and to me is asking for trouble,
especially if myVariable is not a string. It's also very easy to miss one.

So I've had an idea. At the beginning of each function, I'm going to add:

<cfset var local = StructNew()>

Which effectively creates me my own local variable scope. I can then create
variables like local.myVariable, safe in the knowledge that they are local
and thread safe.

Good idea? Bad idea?

Thanks
Ian



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:235867
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=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to