Execution Functions and Evaluation Zones

Waaaay back in 2000, I wrote an article on certain 'laws' of ColdFusion that I used: The Law (according to Michael Dinowitz)

One part of this article was a rundown of what I called Execution Functions. Basically, these were functions that either returned no value or a boolean to indicate success of failure. My 'hard' rule is that there is no need to assign the value returned from these functions to a variable and even that doing so is a waste of memory. I've rewritten that section many times in different places, but this is what is actually happening.

A CFSET tag is divided into 2 parts. One part is the evaluation zone, which is the right hand side of the tag after the equal sign (if an equal sign exists). The evaluation zone will treat anything that is not a number or a string as something to be evaluated. It will also look inside any string for anything surrounded by pound signs and try to evaluate it as well. This zone is a general evaluation zone, so you can even use something like:

This is a comparison which you may see in a CFIF, but will evaluate properly inside the CFSET. If the name variable has a value of "Michael", then the value of IsName will be Yes. Otherwise it will be No.

For an even older article that clearly explains evaluation zones, look here: Evaluation in ColdFusion

The other part of the CFSET tag is the variable assignment. This is a variable name followed by an equal sign and will accept whatever comes from the evaluation zone and assign it to variable. This area is TOTALLY OPTIONAL. There has never been a need to assign the value of the evaluation zone to a variable and doing so basically creates a variable that is usually useless.

So bottom line is that any CF function, UDF, or Component method call (which is basically a UDF) can be used in a CFSET without any variable assignment.

This is what I do and every time I see some code that is running a QuerySetCell() and assigning it to a temp variable, it's the first thing I erase.

You know, I really have to update and republish a lot of my old articles. Lots of good information just buried under the weight of time. :)

Comments
ahxhlq's Gravatar Player friend:come here to experience the pouring , thrilling and lightsome online game, please register the following website ,they will provide the high-speed game agency to every player, the speed and service must be the top-grade absolutely .<a href="http://www.power4game.com">game</a>;
# Posted By ahxhlq | 12/7/06 2:05 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.9. Contact Blog Owner
House of Fusion | ColdFusion Jobs @ House of Fusion | Fusion Authority