TerrenceRyan.com

I'm a 35 year old redhead geek from Philly.
I'm currently a Developer Evangelist for Adobe.
Also the author of Driving Technical Change

Why Isn't There a Local Scope?

3 Comments

I was giving a presentation today on CFC's, and was explaining the difference between the variables scope, the 'local' scope, the this scope, and the arguments scope. It was incredibly hard to explain, mostly because an unscoped variable in a CFC function can refer to either a local, variable-scoped, or arguments-scoped variable.

It made me think, why didn't they just create another default scope named 'local'?

However, I realize the ColdFusion development team has some noggin-horsepower, so I'm sure there is a good reason. I just can't think of it.

3 responses so far ↓

  • 1 Michael Dinowitz

    It gets a little complicated under the hood as a UDFs 'local' scope can be assigned variables in 4 different ways. The first are variables passed into the UDF that also have a CFARGUMENT tag. Variables passed into a UDF without a matching CFARGUMENT tag are NOT automatically part of the local scope. The second are the result of CFARGUMENT tags with default values. The third are CFARGUMENT tags without default values, but this is a special case. CFArgument tags without a default and without a passed value create a 'space holder' for a local variable that can be filled within the UDF. The fourth are variables set with a var prefix inside the UDF.

    I cover this in depth in my "From User-Defined Functions to ColdFusion Components" chapter in the latest FAQ-U (small plug). :)
  • 2 Jeff Porten

    The situation gets even more confusing when a reader mistakenly presumes you're referring to chlorofluorocarbons.
  • 3 Adam Cameron

    Michael... whilst that's all very interesing... how does all that make it difficult to give the local scope a NAME?

    --
    Adam

Leave a Comment









Categories

Monthly Archives

Tag Cloud

coldfusion web development flex coldfusion builder appearances squidhead coldfusion builder extensions higher ed html5 flash builder air mobile android driving technical change adobe apptacular running a coldfusion shop adobemax06 movable type flash catalyst flash css blackberry adobemax07 adobemax08 hero finicky adobemax09 holy crap i’m a mobile developer centaur phonegap basecamp cfc whichelement unfuddle motorola metablog irrational characters ios git evangelism edge devices code reviews ant wharton subversion security rhino philly philadelphia multidevice knowledge@wharton jobs javascript java browserlab adobemax10 adobe tv unfuddlecfc svnauth.cfc semantic html semantic html responsive web design qnx nlb linux jquery mobile it github flexorg fireworks eclipse dreamweaver apps apple adobemax11