Semicolons: mostly unnecessary?

AJ aj at nospam.net
Thu Oct 22 01:22:37 PDT 2009


 Semicolons As Implicit Programming Language Statement Terminators (An 
Analysis in Process)

 Pros:

 1. Makes parsing of certain (they need to be listed) constructs easier (how
 much?) (?).
 2. Adds redundancy which helps diagnose and isolate  (facilitates reporting 
of ) the following common
 programming/syntax errors:
    A.
    B.
 3. One well-defined statement terminator.
 4. No need to think: just assume what C/C++ uses is best, without question.
 5. Does not require long statement line-continuation character (for 
instance, "if" statements with
lots of clauses, and function calls/definitions with lots of arguments).
 6. Prevents subtle bugs.
 7. Facilitates languages that don't have header files.
 8. Makes lexical analysis less syntactic.
 9. Acts as a forward jump point for parser restart on error.
10. Makes select source code more comprehensible.
11.

 Cons:

 1. Makes most source code less comprehensible.
 2. Is redundant with the newline designator.
 3. Is more typing.
 4. Introduces tedium in development of implementations from header files.
 5. Makes Andrei vomit.
 6. Missing semicolons are the #1 bugaboo of all C programmers.
 7. Imposes a requirement on the common case to handle the exceptional case.
 8. Is a crutch for parser developers/stifles parser technology.
 9. Imposes parser's role onto every developer.
10. Allows one to write hard-to-see "do nothings" like: for(;;);
11. Introduces subtle bugs.
12. Allows ignorant jettisoning of header file concept.
13.


Discussion/Analysis

On Pro5, "if" statements with lots of clauses: Parser should parse "if 
statement" as soon as it sees "if" rather than parse general "statement". 
Aren't things like "if" ubiquitous enough to accept them as lexical rather 
than syntactical/semantical?
On Pro5, Function calls/definitions with lots of arguments: same comment as 
on "if" statements with lots of clauses.

On Pro8: Isn't that just a rewording of Con8?


(5/8/08)





More information about the Digitalmars-d mailing list