{"id":28,"date":"2024-12-04T19:12:43","date_gmt":"2024-12-04T19:12:43","guid":{"rendered":"https:\/\/programming.rexthestrange.com\/?p=28"},"modified":"2024-12-04T19:14:03","modified_gmt":"2024-12-04T19:14:03","slug":"what-is-that-garbage-on-your-closing-brace","status":"publish","type":"post","link":"https:\/\/programming.rexthestrange.com\/?p=28","title":{"rendered":"What is that garbage on your closing brace?"},"content":{"rendered":"\n<p>You may have noticed that when I close a block in my code, regardless of the language, I put a comment on the closing brace, like so:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function my_function (&#91;some parameters]) {\n\t...\n}\/\/ my_function;<\/code><\/pre>\n\n\n\n<p>Why do I do this? It was a trick taught to me by my original mentor and, simply it shows what the closing brace closes. When I programmed in Pascal (yes, I am that old) I would do this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function my_function (&#91;some parameters]) begin\n\t...\nend {my_function};<\/code><\/pre>\n\n\n\n<p>Why do I do it? Quite simply, so I know what the closing brace (or &#8220;end&#8221; statement) closes. Why is this useful? I generally have a rule that  no function should be larger than a screenful, but this isn&#8217;t always possible. Furthermore, when the implementation is contained within the overall class (as is the case with most modern languages) and several classes can be contained within a single namespace, the end may be several screens below the opening statement, so I would have a brace and have no idea what it closes. I would have to, either infer from the indenting, or scroll to the top.<\/p>\n\n\n\n<p>It&#8217;s just easier and more convenient to add this tiny comment.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You may have noticed that when I close a block in my code, regardless of the language, I put a comment on the closing brace, like so: Why do I do this? It was a trick taught to me by my original mentor and, simply it shows what the closing brace closes. When I programmed [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-28","post","type-post","status-publish","format-standard","hentry","category-general-discussion"],"_links":{"self":[{"href":"https:\/\/programming.rexthestrange.com\/index.php?rest_route=\/wp\/v2\/posts\/28","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/programming.rexthestrange.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/programming.rexthestrange.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/programming.rexthestrange.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/programming.rexthestrange.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=28"}],"version-history":[{"count":2,"href":"https:\/\/programming.rexthestrange.com\/index.php?rest_route=\/wp\/v2\/posts\/28\/revisions"}],"predecessor-version":[{"id":30,"href":"https:\/\/programming.rexthestrange.com\/index.php?rest_route=\/wp\/v2\/posts\/28\/revisions\/30"}],"wp:attachment":[{"href":"https:\/\/programming.rexthestrange.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=28"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/programming.rexthestrange.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=28"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/programming.rexthestrange.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=28"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}