While I agree with Larry Wall that laziness is one of the primary virtues of a programmer, I also believe that when you are faced with a technique that saves time when coding vs a technique that saves time when modifying 2 years later, you should always choose the later. When you are looking at a piece of code generating errors in the middle of your function, will you remember what 'lcl' means? Or especially '$'? What are the chances your co-workers will identify it?

'local' is more likely to be recognized as a local scope.

I'm not trying to preach, I am just in the unfortunate situation of supporting my own 3-year-old cf code, and I wish I learned this lesson earlier.

-mark

Paul Roe wrote:

so forever i have been doing the following to make sure that I scope
local vars in my functions in my cfc's:

<cfset var lcl = StructNew() />
<cfset lcl.end = 10 />
<cfloop from="1" to="#lcl.end#" index="lcl.i">
etc....

While playing around today i noticed that the following also works:

<cfset var $ = StructNew() />
<cfset $.end = 10 />
<cfloop from="1" to="#$.end#" index="$.i">

Can anyone see a good reason why I shouldn't use the $ to denote
locally scoped variables in functions?


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to 
[email protected] with the words 'unsubscribe cfcdev' as the subject of the 
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
(www.cfxhosting.com).

CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]






----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to 
[email protected] with the words 'unsubscribe cfcdev' as the subject of the 
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
(www.cfxhosting.com).

CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]


Reply via email to