Researcher question – what's the point of semicolons and curly braces?
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Mon May 2 21:23:48 PDT 2016
On 5/2/2016 8:48 PM, Joe Duarte wrote:
> Why are curly braces and semicolons necessary? What information do they
> carry that a compiler could not otherwise reliably obtain?
You are correct in that they are (mostly) redundant. Some ambiguities
can arise because D is not a whitespace delimited language. However, the
real reasons are:
1. Redundancy in specification means the compiler can catch more 'typo'
mistakes rather than having them compile successfully and then behave
mysteriously. If a language has 0 redundancy, then any
8745b48%%&*&hjdsfh string would be a valid program. Redundancy is a
critical feature of high reliability languages.
Many languages have removed redundancy only to put it back in after
bitter experience. The classic is implicit declaration of variables.
2. The redundancy also means the compiler can 'resync' itself to the
input once a syntactic error is detected.
3. It's instantly familiar to those who program already in "curly brace"
languages.
More information about the Digitalmars-d
mailing list