On Mar 19, 2004, at 11:07 AM, Barney Boisvert wrote:
First, the separate arguments scope is an oddity that I've not seen except
in CF. Granted, I don't have familiarity with a terribly large number of
different languages

CF is unusual in having named scopes in the first place. Most languages operate using simple block scoping instead - which allows you to hide declarations with other declarations and then usually not be able to get at the original declaration:


/* C code */
char* foo(int n) {
char* n = "forty two";
return n;
}
int main() {
        printf("foo(42) = %s\n", foo(42) );
        return 0;
}

You get a compiler warning - but it is legal and char* n hides the argument int n.

Second, you can't use argument names in the local variables scope (because
CF makes them local variables behind the scenes). Consequently, you'll
never have a local variable and an argument with the same name, so there is
no need to differentiate the arguments with a scope; they are already
differentiated.

Er, that's not actually true:


<cffunction name="foo">
        <cfargument name="n" type="numeric" />
        <cfset var n = "forty two" />
        <cfreturn n & arguments.n />
</cffunction>

That shows that var n and arguments.n both exist independently...

Third, why complicate things with additional scopes? The named 'arguments'
scope is nothing more than a crutch so you don't have to look at the
CFARGUMENT tags at the top of the function to know what was passed in.

And yet lots of people advocate using the scope qualifier everywhere, even if it isn't really needed, to avoid relying on CF's somewhat complex and non-intuitive scope stack searching. Can you - WITHOUT LOOKING IT UP - list all of the scopes that CF searches in the correct order for an unscoped variable name?


Fourth, having two copies of anything is bad because sooner or later, you'll
screw up and use the wrong one.

Well, that's a mildly plausible argument but of course the same issue exists between "variables" scope and 'var' scope - if you forget a "variables" prefix you may get a local scope variable or an unnamed scope variable. Hence, best practice is to use "variables" everywhere to avoid confusion - or would you rather mix 'var' scope, arguments scope and the unnamed scope altogether?


Fifth, I'm a lazy bastard, and those extra 10 characters add up. ;)

"first of all come great dreams, then a feeling of laziness, and finally a witty or clever excuse for remaining in bed." (Kierkegaard 1813-1855; "The Present Age")


Regards,
Sean

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email.


CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

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

Reply via email to