Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The question is: Wouldn't it be better ?</p> <p>The answer is: That depends, as this sort of thing is entirely subjective. Unless you are, or think like, a machine.</p> <p>Yes, it would satisfy some ache for consistency to enforce begin/end for ALL compound statements, but where the surrounding language elements already provide a natural enclosure, it is utterly redundant to require this.</p> <p>Consider the CASE statement:</p> <pre><code>// "Sensible" syntax case VALUE of 1: DoSomething; 2: begin DoSomethingElse; DoMore; end; else DoForAllOtherValues; DoMore; end; </code></pre> <p>Versus a less sensible but more consistent and "logical":</p> <pre><code> case VALUE of 1: DoSomething; 2: begin DoSomethingElse; DoMore; end; else begin DoForAllOtherValues; DoMore; end; end; </code></pre> <p>Notice that the final "end" is part of the "case". You cannot do without it.</p> <p>I am fairly sure that in an early version of Chrome (that became Oxygene and subsequently Prism) this was actually required syntax for the case statement. If so, it is no longer the case. Common sense presumably prevailed.</p> <p>In my personal opinion, satisfying the OGoSC (Objective Gods of Syntactic Consistency) angers the perhaps lesser, but actually more relevant to you and me, SGoHRaC (Subjective Gods of Human Readability and Comprehension).</p> <p>Though in many cases it might appear otherwise, we humans are not in fact machines. We do not need to simplify and reduce rules to a minimum consistent set to make it possible to parse text and make sense of it. We need some rules, but we can handle more, since our great advantage over machines is a freedom of thought that liberates us from a strict regimen of syntax and structure, especially where such syntax and structure is extraneous to the point of redundancy.</p> <p>As in this case.</p> <p>If you make a mistake that the compiler cannot interpret, it will tell you, every time you compile. But the compiler won't thank you for making the code "easier" to "read" (the compiler simply follows the rules it is given - it does not make it "easier" for the compiler to "read" the code by changing the rules that it can already follow perfectly happily).</p> <p>If you impose arbitrary rules that make it harder to read (not because the rules are more or less invariant/consistent, but because you impose a consistent structure that itself contains more noise and redundant information that has to be filtered) then you will pay the price in human productivity.</p> <p>In fact, these "easier" more "consistent" rules, may actually may make it harder all around ... consider again the CASE statement.</p> <p>To make that compound begin/end make sense, we must make "case" a standalone statement, not part of a case/end pair, thus ALL of these should be valid syntax:</p> <pre><code> case VALUE of 1: DoSomething; 2: DoSomethingElse; case VALUE of 1: DoSomething; 2: DoSomethingElse; else DoOther; case VALUE of 1: DoSomething; 2: begin DoSomethingElse; DoMore; end; else DoOther; case VALUE of 1: DoSomething; 2: begin DoSomethingElse; DoMore; end; else begin DoOther; DoMoreOther; end; case VALUE of 1: DoSomething; 2: begin DoSomethingElse; DoMore; end; </code></pre> <p>You may disagree, but it seems to me that suddenly this more consistent syntax results actually in LESS consistency in the actual code, even though there is greater consistency in the rules that the code is being written to conform to.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload