Why writedump function doesn't require semicolon in cfscript?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 21:25:03

问题


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> 

回答1:


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>


来源:https://stackoverflow.com/questions/6606208/why-writedump-function-doesnt-require-semicolon-in-cfscript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!