> -----Original Message----- > From: Johnny Le [mailto:[EMAIL PROTECTED] > Sent: Sunday, March 27, 2005 10:43 PM > To: CF-Talk > Subject: Re: Best practice question? > > This sounds great, but isn't the args variable has its own scope too? It > is variables scope, isn't it? Since it declares locally in the function, > I am not sure if its scope is variables, but it has a scope of something. > So if you have scope everything, you would have to do > variables.args.MaxCount, right?
No - in the case presented (since the "var" keyword was used) "args" is in the "function local" (also called the unnamed scope). It is NOT in the variables scope and can't be accessed using it. The function local scope is persistent only during the current iteration of the function and is then gone. The variables scope is persistent to the instantiated life of the CFC (which can be quite a long time if the CFC is kept in a shared memory scope). The function local scope is the odd-man-out as to scopes: it's the only CF scope that's not named and not accessible as a struct. This is why I use <cfset var local = structNew() />. By creating this "pseudo-scope" and putting all of my function local vars into it I gain pretty much all of the benefits of other CF Scopes. But understanding the differences between the function local and variables scopes in CFC is tremendously important for building thread-safe applications. Knowing this stuff will save you tremendous heartache later - the bugs that come from this are nasty to track down and only appear under pressure. Jim Davis ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:200186 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

