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.
Archived Comments
Don't tell Ben Nadel or he'll add in line breaks and spaces before every parentheses ;)
Hmm... I think that works with Java/C# too. White spaces generally don't matter, if I'm not mistaken.
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)
function ( x )
all the same thing.
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.
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
@Andrew - funny, I don't think I've ever seen functionSPACE( before, but maybe I just never noticed.
@Ray - There is nothing from stopping you writing code like this either.
function
(
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.
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() {
lots
of
stuff
here
})
hehe....
You can also do this:
<cfscript>
myvar =
/*
Here's my lovely comment about why I'm doing this
*/
CreateObject("component", "mycomponent").init();
</cfscript>