Pritesh Patel
Pritesh Patel

Reputation: 2019

Why writedump function doesn't require semicolon in cfscript?

Normally all statement written in CFSCRIPT tag must end with semicolor (;) but today I was working with sample code where I forgot to write semicolon (;) after writedump() function but still code execute fine. Se below sample code and this work fine with ; at the end of statement. Just curios to know why writeDump work without semicolon.

I am working with Coldfusion version 9,0,1,274733.

<cfscript>
a = "Hello";
b = "World";
concat(a,b);
writeDump(a & b)
writeOutput(a);
</cfscript>


<cffunction name="concat" access="public" output="false" returntype="string">
<cfargument name="str1" required="true" type="string" />
<cfargument name="str2" required="true" type="string" />
<cfreturn str1 & str2>
</cffunction> 

Upvotes: 3

Views: 790

Answers (1)

Sergey Galashyn
Sergey Galashyn

Reputation: 6956

I guess Adobe devs could forgot to apply this pretty useless convention to the CFScript parser... Because it looks like a bug (it is already filed, btw), really. You can even write something like this and it will work:

writeDump(variables)writeDump(a & b) 

Kind of implicit semicolon for this function.

It worth mentioning that Railo went further and made all semicolons optional when single statement present on line, so this will work just fine:

<cfscript>
    a = "Hello"
    b = "World"
    concat(a,b)
    writeDump(a & b)
    writeOutput(a)
</cfscript>

Upvotes: 4

Related Questions