{"id":1189,"date":"2022-08-30T15:13:52","date_gmt":"2022-08-30T15:13:52","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/does-any-other-language-other-than-javascript-have-a-difference-between-brace-start-locations-same-line-and-next-line-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:13:52","modified_gmt":"2022-08-30T15:13:52","slug":"does-any-other-language-other-than-javascript-have-a-difference-between-brace-start-locations-same-line-and-next-line-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/does-any-other-language-other-than-javascript-have-a-difference-between-brace-start-locations-same-line-and-next-line-collection-of-common-programming-errors\/","title":{"rendered":"Does any other language other than JavaScript have a difference between brace start locations (same line and next line)?-Collection of common programming errors"},"content":{"rendered":"<p>The first language where I came across this was awk (which also has its share of syntax &#8220;oddities&#8221;; optional semi colons, string concatenation using only whitespace and so on&#8230;) I think the DTrace designers, which based the D syntax loosely on awk, had enough sense to NOT copy these features, but I can&#8217;t remember off the top of my head. A simple example (counting the number of ENTITY tags in a DTD, from my Mac):<\/p>\n<pre><code>$ cat printEntities.awk \n# This prints all lines where the string ENTITY occurs\n\/ENTITY\/ {\n  print $0\n}\n$ awk -f printEntities.awk &lt; \/usr\/share\/texinfo\/texinfo.dtd | wc -l\n     119\n<\/code><\/pre>\n<p>If this little script instead were written with the brace on a line of its own, this is what would happen:<\/p>\n<pre><code>$ cat printAll.awk \n# Because of the brace placement, the print statement will be executed\n# for all lines in the input file\n# Lines containing the string ENTITY will be printed twice,\n# because print is the default action, if no other action is specified\n\/ENTITY\/\n{ \n   print $0 \n}\n$ awk -f printAll.awk &lt; \/usr\/share\/texinfo\/texinfo.dtd | wc -l\n     603\n$ \/bin\/cat &lt; \/usr\/share\/texinfo\/texinfo.dtd | wc -l\n     484\n$ \n<\/code><\/pre>\n<p id=\"rop\"><small>Originally posted 2013-11-09 23:38:46. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>The first language where I came across this was awk (which also has its share of syntax &#8220;oddities&#8221;; optional semi colons, string concatenation using only whitespace and so on&#8230;) I think the DTrace designers, which based the D syntax loosely on awk, had enough sense to NOT copy these features, but I can&#8217;t remember off [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1189","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1189","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1189"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1189\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1189"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}