March 3, 2014
Language Enhancements in ColdFusion Splendor – Member functions
Comments
(6)
March 3, 2014
Language Enhancements in ColdFusion Splendor – Member functions
Newbie 8 posts
Followers: 0 people
(6)

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 Comments
2014-05-04 23:04:55
2014-05-04 23:04:55

@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

Like
2014-04-09 12:29:49
2014-04-09 12:29:49

Is the first class thing working for anyone? The example from the wiki doc:

ArrayEach([“joe”, “john”, “peter”], ucase)

did not work for me.

Like
2014-03-20 23:39:11
2014-03-20 23:39:11

@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

Like
2014-03-08 20:24:17
2014-03-08 20:24:17

Thank you for adding myQuery.getResult() which returns the same as cfquery’s result attribute.

I’ve added it to the doc here: https://wikidocs.adobe.com/wiki/display/coldfusionen/ColdFusion+Language+Enhancements

Thanks!,
-Aaron

Like
2014-03-04 10:46:02
2014-03-04 10:46:02

“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.

Like
2014-03-03 07:13:23
2014-03-03 07:13:23

List is not a data type!

The List~ functions are string manipulation functions.

Like
Add Comment