Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>[Does anybody know] other grammar "peculiarities" of modern programming languages?</p> </blockquote> <p>One of my favorites, <a href="http://www.modula3.org" rel="nofollow noreferrer">Modula-3</a>, was designed in 1990 with Niklaus Wirth's blessing as the then-latest language in the "Pascal family". Does anyone else remember those <strong>awful fights about where semicolon should be a <em>separator</em> or a <em>terminator</em>?</strong> In Modula-3, the choice is yours! The EBNF for a sequence of statements is</p> <pre><code>stmt ::= BEGIN [stmt {; stmt} [;]] END </code></pre> <p>Similarly, when writing alternatives in a <code>CASE</code> statement, Modula-3 let you use the vertical bar&nbsp;<code>|</code> as either a separator or a prefix. So you could write</p> <pre><code>CASE c OF | 'a', 'e', 'i', 'o', 'u' =&gt; RETURN Char.Vowel | 'y' =&gt; RETURN Char.Semivowel ELSE RETURN Char.Consonant END </code></pre> <p>or you could leave off the initial bar, perhaps because you prefer to write <code>OF</code> in that position.</p> <p>I think what I liked as much as the design itself was the designers' awareness that there was a religious war going on and their persistence in finding a way to support both sides. Let the programmer choose!</p> <hr> <p>P.S. Objective Caml allows permissive use of <code>|</code> in case expressions whereas the earlier and closely related dialect Standard ML does not. As a result, case expressions are often uglier in Standard ML code.</p> <hr> <p><strong>EDIT</strong>: After seeing T.E.D.'s answer I checked the Modula-2 grammar and he's correct, Modula-2 also supported semicolon as terminator, but through the device of the empty statement, which makes stuff like </p> <pre><code>x := x + 1;;;;;; RETURN x </code></pre> <p>legal. I suppose that's not a bad thing. Modula-2 didn't allow flexible use of the case separator <code>|</code>, however; that seems to have originated with Modula-3.</p>
 

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