Stupid ColdFusion Syntax Trick

This post is more than 2 years old.

I was in a development meeting earlier today and the following typo came up on screen:

x = "That's no moon. It's a space station."; writeOutput (x);

Notice the space? What was odd though was that ColdFusion Builder did not flag it as an error. On a whim I tried it and it actually worked. I even added about 20 spaces between the end of writeOutput and the left parenthesis and it ran with no complaints.

Weird - and useless - but kind of interesting how ColdFusion Builder helped me discover something I didn't know you could do.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by Brian Rinaldi posted on 9/1/2009 at 10:28 PM

Don't tell Ben Nadel or he'll add in line breaks and spaces before every parentheses ;)

Comment 2 by Henry Ho posted on 9/1/2009 at 10:28 PM

Hmm... I think that works with Java/C# too. White spaces generally don't matter, if I'm not mistaken.

Comment 3 by Dave DuPlantis posted on 9/1/2009 at 11:35 PM

Yep, that's right. Whitespace is ignored ... which means you get standards wars in most dev groups. When I worked in groups, it was interesting to see how people could be so passionate about things that didn't matter at all to the parser. (Sometimes "people" meant me!)

function( x )
function (x)
function ( x )

all the same thing.

Comment 4 by Andrew Scott posted on 9/2/2009 at 7:47 AM

That is correct Henry, every language I have used is able to do this. If fact in our coding guidelines we actually have it documented that we use a space in this sitaution, and I have seen javaScript with this in a lot of examples in the last 15 years as well.

Comment 5 by Rob Dudley posted on 9/2/2009 at 12:57 PM

I'd second Brian's comment - Mr Nadel makes extensive use of white space in his function calls ... annoys the hell out of me personally but each to their own

Comment 6 by Raymond Camden posted on 9/2/2009 at 3:12 PM

@Andrew - funny, I don't think I've ever seen functionSPACE( before, but maybe I just never noticed.

Comment 7 by Andrew Scott posted on 9/3/2009 at 1:37 AM

@Ray - There is nothing from stopping you writing code like this either.

myVar, // Example1
myVar1, //Example2
myVar2, //Example 3
myVar3, //Example 4

The parser should ignore all spaces, tabs and end of lines until it finds what it needs.

Comment 8 by Raymond Camden posted on 9/3/2009 at 1:40 AM

That's wrong. You must be stopped Andrew. I'm creating a time machine just so I can go back in time and take care of that.

On a serious note - I do employ syntax like that a bit for jQuery.

$("...").foo(function() {

Comment 9 by Andrew Scott posted on 9/3/2009 at 2:35 AM


Comment 10 by Grant Eagon posted on 12/21/2009 at 4:37 AM

You can also do this:
myvar =
Here's my lovely comment about why I'm doing this
CreateObject("component", "mycomponent").init();