Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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> 
like image 845
Pritesh Patel Avatar asked Aug 14 '26 12:08

Pritesh Patel


1 Answers

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>
like image 128
Sergey Galashyn Avatar answered Aug 17 '26 19:08

Sergey Galashyn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!