Monday 26 August 2013

CFML: parameterStillExists()

This is an adjunct to my preceding article, pretty much allowing me go say "One word: parameterExists()" without actually qualifying why I said that that without requiring more than one word.

Most CFMLers probably know there is a function parameterExists() in CFML. Most people will know it's poor form to use it in favour of isDefined(), and really it's poor form to use isDefined() rather than structKeyExists(). Some people will be surprised to hear parameterExists() is still in the language; others will be aware that it's deprecated (and, curse them, others still will think that because it's deprecated that it will no longer work, but I've already covered that).

Now I knew parameterExists() had been deprecated for ages, and I always cite it as having been deprecated for over a decade, and use it as an example of why people should not get all uppity and hand-wringy at the notion of things in CFML being deprecated. We could happily deprecate <cfset> and still expect it to work in ColdFusion 15, in ten years time (no, I neither expect there to be a CF15, nor for anyone to be discussing CFML in ten years time. It was an example).

Anyway, I decided to find out how long it's been deprecated. Up until now I thought it was since CF5, because I have a copy of the CF5 docs, and it's already deprecated there:

This function is provided for backward compatibility with previous versions of
ColdFusion. Y ou should use the function  IsDefined instead.

OK, so the word "deprecated" is not used there, but that's clearly the intent. Anyway, it's already toast in 2001.

I googled about, and found some CF4.5 docs, and in there...

† ParameterExists(parameter)
† Deprecated.
So already deprecated in ColdFusion 4.5. Released in 1999.

I continued the hunt, and found some CF 4.0 docs for parameterExists(). Surely this is where it's still "the way to do things"...

This function is provided for backward compatibility with previous versions of ColdFusion. You should use the function IsDefined instead.
So in 4.0 it was already deprecated. 4.0 was released in 1998. "ColdFusion 4.0" was also the first version to not be worded "Cold Fusion", btw (or so says Wikipedia, anyhow).

I cannot find any docs for "Cold Fusion 3" [...]but I was able to find some docs for Cold Fusion 2! And here we finally answer our question (by inference). Here's the Cold Fusion 2 docs for parameterExists():

Returns "Yes" if parameter has been passed to the current template, or has been already created during execution of the current template. Otherwise returns "No".

So it was not deprecated in Cold Fusion 2.


After revising my search string in Google, I was able to find the Cold Fusion 3.1 docs on HoF too, which clearly state that the deprecation of parameterExists() occurred in 3.0 or 3.1:

This function is provided for backward compatibility with Cold Fusion 2.0. You should use the function IsDefined instead.
So there we go. parameterExists() was deprecated in Cold Fusion 3.1 (or poss 3.0), and that was back in 1997-1998. Based on that sort of inertia, if something was deprecated in ColdFusion 11, we should expect it to still be operational in ColdFusion 19 (or in about 14-15yrs, depending on which metric we're using). Which is... heartening.

Anyone still use parameterExists()?