Saturday 20 April 2013

Completely useless information about a quirk in ColdFusion's CFML

G'day:
I'm just preparing to return to the UK on Tuesday evening (I'm currently in NZ), and as I do not intend to set foot back on these shores for a long time, there's been a lot of beer-drinking with NZ-based mates for the last few days. I was at the pub from 3pm until [I have no recollection of leaving, really] yesterday, and am about to head off to another pub to drink again with some different mates (and some of the same mates again). We're mustering at 1pm. I'm still feeling the rigors of yesterday's effort, and am trying to steel myself to start again. I have about an hour before I need to head out, so this is a very quick and silly article.


Here's some code. Can you spot what's "wrong" with it (this is specifically for ColdFusion users, not Railo users):

<cfscript>
    writeDump(server)
    writeLog(file="foo", text="bar")
    try {
    throw(type="SampleException")
    } catch (any e){
        writeDump(e)
    }
</cfscript>

This runs fine on ColdFusion (9 & 10). What's missing? Semi-colons. There's not a single semi-colon in that.

It turns out that in ColdFusion CFML, pretty much all statements require a terminating semi-colon (except, obviously, block-level control structures), except for writeDump(), writeLog() and throw(). That is weird. And - as Sean pointed out in a comment against another article - it concerns me slightly about what's going on with the CFML parser in that they have exceptions like this to what ought to be a fairly fundamental part of its processing.

I also think these are the only three functions which take name/value pairs for their arguments. Everything else (I think?) requires positional arguments. That's a bit weird too.

What good use can one put this info to? None that I am aware of.

And, yes, I know that Railo's CFML implementation doesn't require semi-colons at all.

Update:
However that code doesn't run in Railo due to an unrelated bug. Oops.

I need a coffee. And some will to live.

--
Adam