Thursday 26 September 2013

Wow: ColdFusion's built-in functions will now be first class in ColdFusion 11

G'day:
Gotta be quick: at work. A while back I wrote an article "Callbacks and built-in functions as first-class functions", and floated the idea of promoting built-in functions to be first class: 3434441.

A few weeks back that ticket got marked "to fix", which I thought was good news.

Even better news: it's now been marked as "fixed/to test". So it's been done! Nice one!!

Update:

I've raised this with Railo too: RAILO-2629.
What this means is that one will be able to treat built-in CFML functions  - eg: listAppend(), ucase(), etc - as objects, being able to assign them to variables, pass them as arguments, etc. Here's a very contrived example:

function genericHandler(required string str, required function callback){
    return callback(str);
}

result = genericHandler("G'day World", ucase);

writeOutput(result);

This would yield:

G'DAY WORLD

That example is not very useful, but I have had other situations in which the callback functionality I've wanted has been fulfilled by a built-in function, and I've needed to do this sort of thing:

function _ucase(required string str){
    return ucase(str);
}

And then use _ucase() instead of ucase().

It's not something I need every day, but it's one of those "better to have and not need, than need and not have". Plus having functions as first class objects seems more "OO" to me, and accordingly makes the language better.

I wish I was on the ColdFusion 11 special testing programme now, so I could test this stuff out. Oh well. When the public beta comes, I guess.

--
Adam