Language Enhancements in ColdFusion Splendor – Member functions

Download the public beta of ColdFusion Splendor from here

I started a series of blog posts on language enhancements and covered “Script support for tags last week. Continuing on this, today I am going to blog about “Member function” that I hope should interest most of you. Before I get into the details of member functions, here is the list of language features:   

  • Script support for tags
  • Member functions for CF data type/data structure
  • Improved JSON serialization
  • Easy to use CF functions for Query tag
  • Elvis operator (?:)
  • Promoting built-in CF function to first class 
  • Miscellaneous new functions: QueryGetRow, ListEach and others. 
ColdFusion predates object-oriented programming (OOPs) and hence did not have support for OOPs syntax. If you had to perform an action on an array, a struct or say on any other CF datatype, you had to call the headless functions like “ArrayAppend” or “StructFind” prior to Splendor. Now, with addition of “Member functions” support in Splendor, you can now enjoy writing your code in true object oriented-style and can call find() method on a struct object. For instance, empStruct.find(“empID”). The code snippet shown below will help you visualize these two different coding styles:


Headless function

<cfscript>
     ArrayAppend(empArray, newObject);
     StructIsEmpty(empStruct);
</cfscript>

As member function of array/Struct

<cfscript> 
     empArray.append(newObject);
     empStruct.isEmpty();
</cfscript>

The Member function support in Splendor is quite exhaustive and covers most of the data types present in ColdFusion. The complete list of data types supported are:

  1. String
  2. List
  3. Array
  4. Struct
  5. Date
  6. Image
  7. Query
  8. SpreadSheet
  9. XML
Member function supported under each data type has been listed in ColdFusion Splender public beta documentation. Please see the documentation for more details.
Stay tuned for more on language enhancements in Splendor..  

6 thoughts on “Language Enhancements in ColdFusion Splendor – Member functions

  1. “ColdFusion predates object-oriented programming” — Not true.

    I’d been writing C++ for several years before CFML 1.0 appeared and Ruby, Python, Java and others are all about the same age as CFML and full-fledged OOPs.

  2. @Aaron: I suppose qry.getResult() is not a member function, since there is no such function as queryGetResult(). It is rather an undocumented Java method of the query method.
    I guess now more of these undocumented methods will pop up in the CFML engines, since with member functions available people will go hunting for oop like notation on complex objects.

    Gert

  3. @Gert,

    I think the Member Functions docs page is now confusing. You’re right, queryGetResult() doesn’t exist – even tho it’s mentioned on that page. However, I filed the ER for q.getResult() which didn’t exist in CF10. (I don’t take credit for q.getResult() tho b/c I believe it was requested before by others)

    Thanks,
    -Aaron

Leave a Reply

Your email address will not be published. Required fields are marked *