[thelist] <cfset> vs <cfscript> for a simple function call

Sarah poohbear at designshift.com
Wed Jul 16 09:36:20 CDT 2003


> ><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> > I'd also argue that cfset isn't just a tag used for
> > assignment.  It simply, for lack of a better word,
> > executes expressions. The following is perfectly valid,
> > and works just fine in CF5 and up:
> >
> > <cfset 1 + 1>
> ><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
>
>sure, but the docs are very clear what the <cfset> tag is for.
>
>   "Defines a ColdFusion variable. If the variable exists,
>    this tag sets it to the specified value."
>
>the fact that the parsing engine allows you to get sloppy with its usage
>doesn't make it ok, in my book.
>
> ><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> > Sure, you get more results with <cfset var = something>,
> > but it's no less valid, syntax-wise, to say
> > <cfset 1 + 1>.
> ><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
>
>based on the documentation, that is invalid, syntax wise because the results
>of the expression are not being assigned to a variable.  granted, you're
>correct that it won't throw an error, but that doesn't mean it shouldn't.
>
> ><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> > I do, however, agree with you, to a degree. It just
> > doesn't seem right, but it actually isn't incorrect,
> > syntax-wise, performance-wise, or arguably
> > readability-wise. It comes down to personal preference.
> ><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
>
>well, imo, it's definitely a huge issue with regards to readability.  when
>you're scanning code looking for where stuff is happening, a <cfset> tag
>used "improperly" like this can easily slip through the cracks unnoticed.

Nice to see that I've started an interesting debate :) I actually agree 
with both of you, but I have always felt that the most annoying part of 
ColdFusion was not being able to just call a function without having to use 
a <cfscript> block or something silly like <cfset temp = SomeFunction()>. 
So, in rebellion, I lean towards using <cfset> in the "improper" way.

Sarah



More information about the thelist mailing list