Temp variables to call functions - any point???

I never really thought of this before, but when calling a CF function I've always done something like this:

<cfset myQuery = queryNew("turnOverWeek,budgetWeek,turnOverYear,budgetYear")>
<cfset newRow = queryAddRow(myQuery,1)>
<cfset temp = querySetCell(myQuery,"turnOverWeek",59000,1)>
<cfset temp = querySetCell(myQuery,"budgetWeek",100000,1)>
<cfset temp = querySetCell(myQuery,"turnOverYear",2000000,1)>
<cfset temp = querySetCell(myQuery,"budgetYear",3000000,1)>

I just looked up queryNew() in cfQuickDocs (excelent site), and when I saw it done this way in the example, it got me thinking. We don't want any variable called "newRow" or "temp". So why bother, when the following works just as well:

<cfset myQuery = queryNew("turnOverWeek,budgetWeek,turnOverYear,budgetYear")>
<cfset queryAddRow(myQuery,1)>
<cfset querySetCell(myQuery,"turnOverWeek",59000,1)>
<cfset querySetCell(myQuery,"budgetWeek",100000,1)>
<cfset querySetCell(myQuery,"turnOverYear",2000000,1)>
<cfset querySetCell(myQuery,"budgetYear",3000000,1)>

Are there any pros or cons I am not aware of? Or is it just a personal preference?

As for now I think the last version is better in that it entails less typing, and I actually find it more readable.

What do you think?

Comments
In the documentation it says use something = function() but I generally dont use that (maybe I should?). I think the reason for that is the name of the tag, CFSET. Mentally you would say "set variable equals to function" but then again, I might be wrong?
# Posted By Mark Drew | 11/22/06 7:09 AM
Agreed. I never use them either for these types of functions. Since the variable doesn't carry any useful value it feel inherently inefficient.
# Posted By Brian Rinaldi | 11/22/06 7:16 AM
Hey Trond, as promissed in the CFDEVCON, I just released my blog (http://www.placona.co.uk/blog/). Sorry for the spam, but I wanted to let everyone now.
# Posted By Marcos Placona | 11/22/06 9:27 AM
Hey Trond,

Glad you made it back safely from the conference.

I never use these kind of temp variables and this is one of the reasons I like to use cfscript where I can as <cfset Object.Method()> (as opposed to simply object.method()) seems pretty strange to me, but it is better than having a variable that is not required.

Code is much more readable if you can distinguish between methods and functions that have a return value and those that don't (or whose return value you are not interested in). The Temp variable muddies this up.
# Posted By Peter Bell | 11/22/06 1:56 PM
Hi Trond,

Like Peter, I prefer to use cfscript for this kind of thing wherever I can. However, sometimes it's just "nicer" to do it in tag form, and in that case, I prefer explicitly assigning the result to a var-scoped variable, so that I *know* that the result will get cleaned up at the end of the function.

e.g.

<cfset var garbage = "" />
<cfset newRow = queryAddRow(myQuery,1)>
<cfset garbage = querySetCell(myQuery,"turnOverWeek",59000,1)>

As far as I can tell, it's just a personal preference, but I prefer to be explicit about things wherever i can.
# Posted By Al Davidson | 11/23/06 11:41 AM
# Posted By Michael Dinowitz | 11/23/06 1:32 PM
Hi Trond,

These variables are no longer needed - in previous versions of CF 4.5 or 5 the cfset tag always required an assignment to happen.

Since MX (I think) this is no longer necessary - so there is no advantage in the 1st method unless you are looking for serious backwards compatibility!

Cheers,
Mark
# Posted By Mark Lynch | 11/23/06 1:39 PM
Um mark, your totally wrong here. CFSET has never to my knowledge (which goes back to June 95) needed a left hand side of a CFSET. There is no compatibility issue.
# Posted By Michael Dinowitz | 11/23/06 1:43 PM
Sorry, Mike, but I have to side with Mark, although I think he's got the version numbers wrong. When the tags in question were introduced (ColdFusion 4.0), cfset required a value to left of the equals sign. It generated a very specific error message stating such. This was quickly corrected by ColdFusion 4.0.1. However, the documentation had already been written. Precedence had already be established. So it stands.
# Posted By Ben Rogers | 11/24/06 12:19 AM
Its times like this that I wish I had a spare box to install an earlier version of CF on to test this out. On the other hand, I will look through the docs to verify this (I have them all here back to 1).
I'll report on this once I actually wake up. :)
# Posted By Michael Dinowitz | 11/24/06 12:51 AM
Hi Michael,

Really nice article. Not sure if the small performance gains for cfscript are still true (was it you that said somewhere that had changed in a recent version of CF or am I just spaced out after too much Turkey?!)

While it IS a matter of preference, I'm pretty strongly in favor of no unnecessary variable assignments. If you have a function or method that ONLY has side effects (doesn't have a return value) or where you don't care about the return value, I think it is actually a little misleading to assign that to a variable.
# Posted By Peter Bell | 11/24/06 9:56 AM