Jim Davis wrote:
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf
Of Paul Roe
Sent: Tuesday, July 05, 2005 4:27 PM
To: [email protected]; [EMAIL PROTECTED]
Subject: [CFCDev] Functions local scope

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?
    

I'd be more interested in hearing your reasons why you think you should.
;^)

It just seems ugly to me.  I would find it obtuse and confusing.

It works because you can use a currency symbol as a variable name in CF -
nothing more.  There's nothing different or special about that.

Jim Davis
  
PHP anyone?  Reminds me of bad CF coding with a ton of un-needed #'s all over the place.  Ditto on the hearing more about the argument.

FYI - At LiveDocs:
http://livedocs.macromedia.com/coldfusion/7/htmldocs/00000080.htm

Barney is right that "each name must begin with a letter" [livedocs] and I would agree that even though $ works - would suspect that it is a bug or undocumented "feature" of the CFMX engine.

As for the debate over var-ing everything or creating a local var struct...I'm not getting into that [I've stirred the pot enough these days ;-)].

Best,
.Peter
-- 
Peter J. Farrell :: Maestro Publishing

blog	:: http://blog.maestropublishing.com
email	:: [EMAIL PROTECTED]

Create boilerplate beans!
Check out the Mach-II Bean Creator - free download.
http://blog.maestropublishing.com/mach-ii_beaner.htm

 If anything can go wrong....it will....at the worst possible moment.

-- ----------------------------------------------------------
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