-1

A question about semicolon ; in language C

in shell script, if write multiple lines into one single line, semicolons are utilized.
date; cal; time

else, write multiple lines into a file:

date
cal
time

semicolons are omitted, it is logical because there exists implicit line delimiters.
python inherits the style.

Nonetheless, in C and its successors like java and JS More tidies effort should be taken to type ; after every single line.

I read Semicolon - Wikipedia, it seems more of an arbitrary choice by modern language.

What’s the rule that C have to confirm so as to inherit such a pattern from B.

AbstProcDo
  • 19,953
  • 19
  • 81
  • 138
  • Is the question why semicolons are still used? why you can place semicolons multiple times `int a = 1;;;;;;`? or what exactly? – X39 Oct 25 '18 at 11:55
  • 1
    It's unclear what your question is. Are you asking why we need delimiters in programming languages? – UnholySheep Oct 25 '18 at 11:56
  • 3
    Programming languages are of two kinds: some consider that ends of line terminate statements by default, and therefore need a special syntax to indicate line continuation; the others consider that ends of lines are the same thing as spaces, and need a special syntax to indicate end of statement. Your pick. – AlexP Oct 25 '18 at 11:57
  • 1
    https://stackoverflow.com/questions/2771266/semicolon-in-c?rq=1 – Mat Oct 25 '18 at 12:00
  • 1
    Languages with C, C++, C#, Java, etc are free-form languages. This means the compiler needs some kind of symbol to know when your statement ends. Other languages, such as BASIC or VB.Net, for example, know where your statement ends because it is not free-form and each statement is on one line. – Icemanind Oct 25 '18 at 12:04
  • this do answer the question. @Icemanind – AbstProcDo Oct 25 '18 at 12:06
  • "More tidies effort are taken to type ; after every single line." If you type with ... like 1 character per second or less. Else no, there is no problem with typing `;` at the end of each line – bolov Oct 25 '18 at 12:07
  • > What’s the key rule govern this style? The "key rule" that governs this style is described in [C language standard](https://port70.net/~nsz/c/c11/n1570.html). The standard says that each expression statement must end with a semicolon, per [6.8.3](https://port70.net/~nsz/c/c11/n1570.html#6.8.3). – KamilCuk Oct 25 '18 at 12:07
  • 1
    In the for example [posix shell](http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html) as command separators are used newlines list (1 or more newlines) ,`;` or `&`, per '2.10.2 Shell Grammar Rules' – KamilCuk Oct 25 '18 at 12:09
  • 1
    C++ is derived from C, which is a product of the early 1970s, when 256 kwords was a lot of very expensive memory. The C language grammar was written with an eye towards being easy to parse, resulting in relatively small, fast compilers. The tradeoff is that the language is a bit harder for humans to write and read. Note that Pascal and its descendants also make liberal use of semicolons, but as statement separators rather than statement terminators. – John Bode Oct 26 '18 at 13:09
  • amazing, could you do a favor transmit the comment to answer. @JohnBode – AbstProcDo Oct 26 '18 at 13:42
  • @JawSaw - since the question is marked as a dup, no new answers will be accepted. And, I can't *prove* that's why C was designed with explicit statement terminators; other considerations in the grammar may have forced their use. – John Bode Oct 26 '18 at 15:31

1 Answers1

3

C came from B which in turn came from a language called BCPL.

A superior statement separator was required for B as the grammar became more complex, and the semicolon was a good candidate. The colon was already in use by then and the period used as a decimal separator.

After that, with the introduction of C, the semicolon became the standard.

Bathsheba
  • 231,907
  • 34
  • 361
  • 483
  • The semicolon was 'standard' long before C came along. Probably the Algol family started it. KDF9 Usercode (an assembly language) also used semicolon as a statement terminator, though that was likely Algol-inspired. –  Apr 29 '19 at 22:51