portal entry

select a category, or use search below
(searches all categories and all time range)

Writing CFMs without Semicolons

| View in Portal
July 12, 2018 08:39:17 AM GMT
<p>Semi-colons have been statement separators for most programming languages. Earlier when processing was slow and memory was expensive, language designers needed to split programs into multiple statements. A few languages required each statement to be on a new line so that the carriage return acted as a delimiter. Some languages required a free format text layout as a separator. Thus, the semi-colon was chosen as a separator so that it doesn’t conflict with other characters, for example, operators for math operations. Many languages do not use semi-colons as statement separator, for […]</p>
<p>The post <a rel="nofollow" href="https://coldfusion.adobe.com/2018/07/writing-cfms-without-semicolons/">Writing CFMs without Semicolons</a> appeared first on <a rel="nofollow" href="https://coldfusion.adobe.com">ColdFusion</a>.</p>
Labels: Adobe ColdFusion, Adobe ColdFusion 2018, Blog, ColdFusion, CFML, coldfusion 2018, semicolon


Your include example requiring semicolons makes no sense. include "blah.cfm" writeoutput("test") is totally clear as the speach marks indicate the file names. If you really wanted to include a file called "blah.cfm" writeoutput("test" then you'd need to escape the marks, just link in any other string.
Comment by Tom Chiverton
1172 | July 13, 2018 09:39:05 AM GMT
Thanks Tom for the feedback, i have added a more appropriate use-case which shows a scenario where semicolons can be used to avoid the ambiguity.
Comment by Ashudeep Sharma
1188 | July 16, 2018 07:16:57 AM GMT
We updated to 2018 this year and I was pleasantly surprised to see that semi-colons were no longer required. Thank you!
Comment by Phillip Senn
2441 | October 15, 2019 06:51:18 PM GMT
Pointless feature. The exceptions where you must use a semicolon actually serve to highlight weaknesses inherent in the language. `param name="num" default="3" max="100";` If CF where a true OO language these would just be properties.
Comment by Savaticus
2477 | October 28, 2019 03:49:08 PM GMT
It's not "pointless", when the very reason indicated for doing it above is to be more consistent with other languages, and when folks here and in other discussions on the web celebrate it. It may not be YOUR cup of tea (for them to have bothered), but do you really need to piss in the cup of others? As for that edge case where the semi-colons are still needed, that's not so much an "inherent weakness in the language". That older param variant for cfparam in script is merely a way to do it that was added originally in the previous decade. Since CF11 (from 2014), one CAN write about any tag as script, and one could pass the args in a way that does not require semicolons: cfparam(name="num",default="3") or cfparam(name:"num",default:"3") If you may feel that's still not suitable to a "true OO language", can you share how you would prefer to see it be written instead? Enlighten us, rather than denigrate. Or if your beef is not so much with param/cfparam, or semicolons, but some other facet of CF that is lacking in OO sensibilities, share that or those.  You may be surprised that many you would list have long-since been addressed, but if you're really wanting to advance the conversation, here's a good chance.
Comment by Charlie Arehart
2479 | October 28, 2019 05:21:31 PM GMT