tag:blogger.com,1999:blog-8955216254487268072.post3766170292436031747..comments2023-03-27T01:10:23.040-07:00Comments on Fingers Dancing: ColdFusion musings on variable scopeRoss Phillipshttp://www.blogger.com/profile/05098392452454494192noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-8955216254487268072.post-90810064120636778182011-02-28T18:06:47.076-08:002011-02-28T18:06:47.076-08:00@Doug yep I agree with your statement. Can't ...@Doug yep I agree with your statement. Can't say I like the term "memory leak" though I've found CF developers using the term to describe exactly what you have described. But thinking about it now I should have left the term out.<br /><br />I suppose my intended sentiment was that the excessive use of "local" is a syntax problem we should not need to deal with as CF developers in general.Ross Phillipshttps://www.blogger.com/profile/05098392452454494192noreply@blogger.comtag:blogger.com,1999:blog-8955216254487268072.post-76907136356628651112011-02-28T07:15:44.404-08:002011-02-28T07:15:44.404-08:00Just thought I would mention using var isn't a...Just thought I would mention using var isn't about memory leaks, its about data leaking across functions in a cfc. An easy example is to create a cfc with two functions and no 'var' on any variables. in function a run a random query. in the second function, check the value of queryname.recordcount. then create a test page where you create the cfc and call function a then function b on the same instance of the cfc. instead of an undefined error, you will get the record count from that other function.<br /><br />this causes really hard to diagnose/reproduce errors (perhaps the 'i' counter from one function is overwriting another loop with the same counter name )<br /><br />so in my opinion, if someone wants to var scope the 'local' struct as a way to make sure variables are not missed and unscoped, it beats the alternative...doug shttp://evenamonkey.comnoreply@blogger.com