[Looking for Charlie's main web site?]

The Ultimate Var Scope Resource list? Understanding/resolving problems with the var scope in CFML

If you or anyone you know ever wants to get up to speed on the "var scope problem" in CF, you may be challenged by the fact that there are many discussions of the topic, spread across many blogs. I've accumulated here a starting list of several of the key ones I know of. I certainly may have missed some, so I welcome suggestions of more.

I think it's helpful to have all the resources in one place. Indeed, ultimately I'll move this to my "resource lists" page where I keep similar "compendia".

I created the list of VAR scope resources today after helping a client with a problem which seemed related to this classic problem: the need to remember to var scope your variables in CFCs. It's often the cause of subtle bugs. Like many, they still hadn't heard about the problem (or had seen mention of it but didn't really understand it).

So if you're in that place, or know someone who may be, here are resources to help get started on understanding the topic and related issues. As always, the CF community has rallied the troops on the matter, and several folks have blogged in various detail or on various related aspects.

About the resources

The first few elaborate on the problem, and the first one even includes a live running example to demonstrate the point. Then a couple explain some related issues.

I also then list resources on the related new "local" scope in CF 9, and some more that discuss compatibility issues with that.

Note that these may have been written any time in the past couple/few years, so keep that in mind and be sure to check the comments as well.

The resources

First, some general resources introducing the var scoping issue/feature:

And some that address various issues related to using the VAR scope:

And some on the change in CF9, for the local scope:

And some tangential discussions of that, including some compatibility issues with the new scope:

The VarScope tool

Finally, of course, as most of these resources point out, be sure to use Mike Schierberl's wonderful varscoper tool to help find whether you have instances of this problem. It tells you literally what to change, where, to don't let concern of this problem overwhelm you.

Conclusion

Hope those are helpful. Again, it's just a starting list. I welcome additions, and I look forward to your comments. In time, I'll move this (and any suggested additions) to my "resource lists" page. Check that out for similar lists of resources on various subjects.

Comments
Sami Hoda offered links to additional discussion that he'd raised when CF9 came out, about the potential incompatibility of the new local scope with existing code. Added those links to the last list above. Thanks, Sami.
# Posted By charlie arehart | 3/4/10 8:50 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.005.

Managed Hosting Services provided by
Managed Dedicated Hosting