CF9 Enhancement Slip

While demoing the ORM features in Centaur (CF9) and Bolt (the CF IDE) during the MAX keynote, I showed and executed some code, and this snippet appeared on the screen for a short time:

I have now received three e-mails asking if that code was real or not. And the answer is yes, that is real code generated by Bolt, and it really was running in Centaur. Really! And yes, I know the code is not great (heck, it’s not even that good, good thing we’re not shipping yet).
But, you have to wonder, what made them ask? And did we inadvertently let a CF9 enhancement slip out of the bag? 😉

8 responses to “CF9 Enhancement Slip”

  1. charlie griefer Avatar
    charlie griefer

    looks like var declared variables no longer need to be grouped at the top of the function body.
    <cfset var Destination = … /> is preceded by a <cfif> block.

  2. Ben Forta Avatar
    Ben Forta

    Good catch! 😉
    — Ben

  3. Bryan F. Hogan Avatar
    Bryan F. Hogan

    Is there an example of why allowing the var scoping of variables anywhere in the function be a benefit?

  4. charlie griefer Avatar
    charlie griefer

    i suppose if nothing else, it just offers for a bit more flexibility.
    <cfif condition>
    <cfset var myVar = "foo" />
    <cfset var myVar = "bar" />
    …without having to explicitly set the <cfset var myVar = "" /> prior to the conditional (but you still could if you wanted to predefine the vars at the top of the function body).

  5. marc esher Avatar
    marc esher

    is that struct notation as an argument to a function I see before me?

  6. John Whish Avatar
    John Whish

    I don’t see the "i" variable used in the loop being var scoped anywhere…

  7. Calvin Avatar

    "Is there an example of why allowing the var scoping of variables anywhere in the function be a benefit? "
    I think the real question is, "is there a benefit to limiting declaration of function local variables to the beginning of the function?"
    I would say that there isn’t. Everywhere else that I ‘declare’ local variables I do so as close to the usage of the variable as possible, the current requirements for var break that proximity convention that can be used in: C#, JavaScript, ActionScript, Java and elsewhere in CF. (note: I am not thinking strictly of the keyword var in this observation, but local variable declaration).

  8. John Allen Avatar
    John Allen

    I am sooooooooooo excited I wont be able to sleep tonight. Ohhhhh Ohhh :
    <cfset var Destination = EntityLoad("Destination", {}, "#arguments.gridsortcolumn# #arguments.gridsortdirection#")/>
    I’m way to excited about this.

Leave a Reply