CFML Enhancements Coming Soon

In addition to all of the new features planned for ColdFusion Centaur, and the introduction of the new ColdFusion IDE, we've also managed to sneak in lots of smaller CFML enhancements, some of which are long overdue. Here are some of what we've been working on.

  • Assignments can now be chained, so this will work:
    view plain print about
    1<cfset a=b=c=d=e=f=1>

  • Ternary operators are now supported:
    view plain print about
    1<cfset a = (b &lt; c) ? b : c>
  • In ColdFusion 8 we allowed you to create structures and arrays implicitly, like this:

    view plain print about
    1<cfset struct={bold=TRUE, alignment="center"}>

    The problem is that we didn't quite finish the implementation, and so if you wanted to pass that structure to a tag or function you'd have needed to first save it to a temporary variable, like this:

    view plain print about
    1<cfset struct={bold=TRUE, alignment="center"}>
    2<cfset SpreadsheetFormatRow(sObj, struct, 1)>

    This has been fixed in Cenatur, and the following will now work (as it should have before):

    view plain print about
    1<cfset SpreadsheetFormatRow(sObj, {bold=TRUE, alignment="center"}, 1)>
  • A new <CFCONTINUE> tag has been added, to complement the existing continue CFSCRIPT operator.
  • Support for "finally" has been added via a <CFFINALLY> tag and a finally operator.
  • One of the biggest CFML enhancement is in CFSCRIPT which now supports all of CFML (with minor exceptions where not appropriate). You can now build CFCs entirely in CFSCRIPT, including Application.cfc. You can invoke any tags and functions in CFSCRIPT. You can use new operators like abort, exit, include, and throw, to simplify your CFSCRIPT. In fact, you can now build a complete ColdFusion application entirely in CFSCRIPT, without using any CFML, if you are so inclined.
  • To make the CFSCRIPT enhancements work properly, we've also added a few new functions, WriteDump() is the equivalent of <CFDUMP>, WriteLog()is the equivalent of <CFLOG> (both of these are named similarly to the existing WriteOutput() function), Trace() is the equivalent of <CFTRACE>, Location() is the equivalent of <CFLOCATION>, and Throw() is the equivalent of <CFTHROW>.
  • ColdFusion variables (including complex types like arrays, structures, queries, CFCs, and Java objects) can be serialized to binary objects using the new SaveCFObject() function, and then deserialized later as needed using LoadCFObject(). These functions can work with variables as well as files, so objects can be serialized to disk and then read later when needed.

And we're not done yet. Stay tuned, more cool stuff to follow!

Related Blog Entries

Comments (28)

  • Lionhart

    The ternary operator makes me smile, Ben.

    #1Posted by Lionhart | Jul 9, 2009, 11:12 AM
  • Rick O

    Seconded about the ternary operator. I know the other changes are awesome, too, but I've been whining for a ternary operator for 10+ years.

    #2Posted by Rick O | Jul 9, 2009, 11:17 AM
  • TJ Downes

    So what have these guys been doing with all the spare time they have on their hands Ben?

    #3Posted by TJ Downes | Jul 9, 2009, 11:22 AM
  • Jared Shields

    Do you think a CFSCRIPT version of CFQUERY will makes it way in?

  • Ben Forta

    Jared, yes, it will.

    --- Ben

    #5Posted by Ben Forta | Jul 9, 2009, 11:54 AM
  • Tony

    I am interested in seeing an application.cfc written entirely in cfscript.

    #6Posted by Tony | Jul 9, 2009, 12:03 PM
  • Jared Shields

    Awesome! Now if only a release date would be announced so that we can plan our overhaul w/ ORM integration accordingly.... We're putting off the integration of Hibernate until CF9 comes out to prevent having to go backwards....

  • JAlpino

    Its great to see these subtleties being included in the new release along with important features like <cffinally>.

    #8Posted by JAlpino | Jul 9, 2009, 12:38 PM
  • Russ Johnson

    This may not sit with others but I would like to see a new file extension for CFSCRIPT only files. Instead of having to use the CFSCRIPT tags to open and close the file, just name the file FILENAME.CFS or something like that. Not a major thing, just something I was thinking about.

  • Ben Forta

    Russ, way back in CF5 days we talked about a CFS file, a file which was all CFSCRIPT and did not need the <CFSCRIPT> </CFSCRIPT> tags. Would be a bit trickier now, as we'd need two of those, one for .CFM files and one for .CFC files. But, still a worthy idea for a future enhancement.

    --- Ben

    #10Posted by Ben Forta | Jul 9, 2009, 12:47 PM
  • Ciaran A

    Thanks for the updates. What will the CFSCRIPT version of <cfquery /> look like?

    #11Posted by Ciaran A | Jul 9, 2009, 01:30 PM
  • Sean Corfield

    "You can invoke any tags and functions in CFSCRIPT."

    Will that include the ability to invoke custom tags in CFSCRIPT?

  • Bradley Moore

    Are there plans to skip the "save to a variable" step for functions that return queries/arrarys?

    For example:

    <cfoutput query="returnsAQuery()"></cfoutput>

    Instead of the current way:

    <cfset myQuery = returnsAQuery() />
    <cfoutput query="myQuery"></cfoutput>

    #13Posted by Bradley Moore | Jul 9, 2009, 02:51 PM
  • Joe Meboe

    Hi, Ben, still looking for something on SharePoint integration. It would be great to be able to read a SP entry (or a set, possibly a date range) out of SP instead of having to export SP records. Thanks.

    #14Posted by Joe Meboe | Jul 9, 2009, 11:34 PM
  • Rupesh Kumar

    Russ, For CFCs that are written in cfscript style, you do not need to write <cfscript>. You just write it in the cfscript syntax.

  • Anthony

    I can't wait for SaveCFObject()!!!

    #16Posted by Anthony | Jul 10, 2009, 11:19 AM
  • Marius M

    can you comment on any updates regarding exchange (availability of last datetime update of a record) and Sharepoint integration.


    #17Posted by Marius M | Jul 10, 2009, 11:34 AM
  • ziggy

    >>and Throw() is the equivalent of <CFTHROW>

    So why not Dump() and Output(), etc? Why the verbose addition of "write"?

    #18Posted by ziggy | Jul 11, 2009, 02:10 AM
  • Manjukiran

    Hi Sean, custom tags are not supported in CFSCRIPT. Also, not all tags can be used in cfscript. We have added script support for most of the frequently used tags - cfquery, cftransaction, cflock, cfmail, cfthread, components, functions, cfthrow, cfrethrow, cffinally, cfexit, etc. Please refer the documentation for the whole list of attributes.
    Some of the tags for which script syntax is not supported - cfpop, cfimap, UI tags like cfgrid, etc.

  • Sean Corfield

    @MJ, thanx for the clarification. I'm just looking at the CF9 Public Beta docs now to see what you guys decided to support in the end. Great work!

  • Randy Leinen

    Does anyone know if there is support for connecting to more than one datasource in the CF9 ORM? I just read through the beta docs and I don't see a way mentioned.

    #21Posted by Randy Leinen | Jul 13, 2009, 02:26 PM
  • Manjukiran

    Hi Randy, ColdFusion-ORM does not support multiple datasources. ColdFusion-ORM is designed to work with one datasource only, which you configure in Application.cfc (this.ormsettings.datasource=<datasourcename>).

  • Randy Leinen

    So then, if my application has multiple datasources then I cannot use the new ORM in CF9?

    #23Posted by Randy Leinen | Jul 13, 2009, 02:34 PM
  • Manjukiran

    There had been a lot of discussions around supporting multiple datasources in Coldfusion-ORM all through the release. We had to make a trade-off between design-simplicity and supporting-multiple-datasources-per-application. We took the approach of keeping the design simple by supporting one-datasource-per-application. For applications which use multiple datasources, you could use the ORM approach for the primary datasource and revert back to the cfquery-based approach for the other datasources. Of-course let us know if you think otherwise.

  • adam j. sontag

    I was just looking at the cf9 docs and didn't see any new functions for creating queries, nor is there one for creating new threads. Is the documentation 100% up to date, or is ORM the only way to access the DB via cfscript?

  • Randy Leinen

    I appreciate the info. And I will admit that there is a lot to like and look forward to about CF9. And the ORM looks very promising. However, using an ORM for part of the data access is not a good idea. The benefit of medium to large projects is in having it all managed by the ORM. So, although I will upgrade to CF9 when it is released, I will not be using it for ORM. And this really disappoints me. I am just converting a windows app to a web/flex app using flex and cf. So, I guess I will have to look into using transfer - unless you have other suggestions. Also, it would seem to me that any medium sized application is likely to have multiple datasources, and therefore, is unlikely to use CF9 ORM until that feature is available. This is just my opinion. Thanks for any input you have.

    #26Posted by Randy Leinen | Jul 13, 2009, 04:17 PM
  • Russ S.

    I've written a complete Application.cfc reference in CFScript for Coldfusion 9. You can see it here:
    It includes all available methods and variables, and is fully commented.

    #27Posted by Russ S. | Dec 12, 2009, 05:03 AM
  • Russ S.

    Forgot to include the link to my Application.cfc reference:

    #28Posted by Russ S. | Dec 12, 2009, 05:05 AM