[thelist] Justification for Proper Scoping?

Warden, Matt mwarden at odyssey-design.com
Sun Apr 22 05:56:42 CDT 2001


> >  You will have to check for yourself the ColdFusion
> >  precedence between the variable coming off the url and
> >  form. I may have it backwards--though my point is the
> >  same. You still lose the ability to be dogmatic and
> >  controlling, which is what really brings a smile to most
> >  programmers' faces.
>
> I'm not quite clear on what you mean. Are you suggesting that the
> emphasis that I place on (what I consider being a good discipline)
> correctly scoping a variables is wasted time, due to Cold Fusion's
> flexible handling of the matter?

I don't know much about CF, but I know that in most languages, you can
access certain variables like querystring variables and form variables
multiple ways. In ASP:


request("myvar")
request.form("myvar") or request.querystring("myvar") or etc....


in PHP:

$myvar
$HTTP_GET_VARS['myvar'] or $HTTP_POST_VARS['myvar'] or etc...



so, what I assume he's talking about is how it is better to access CF vars
as #form.myvar# rather than #myvar#. Like I said, this goes for most
languages.



The problem comes in when you are expecting #myvar# to come from a form.
But, what if someone appends ?myvar=1 to your URL? Then, does CF give you
the form value or the querystring value? That's where the problem comes in
(unless you want this to be a possibility). Referring to vars as
#form.myvar# forces CF to give you the value from the form, not the
querystring... in other words, there's no question of where the value is
coming from. Same with ASP and PHP and most other languages.



hth,



--
mattwarden
mattwarden.com





More information about the thelist mailing list