Researcher question – what's the point of semicolons and curly braces?

tsbockman via Digitalmars-d digitalmars-d at puremagic.com
Wed May 4 11:11:52 PDT 2016


On Wednesday, 4 May 2016 at 05:45:39 UTC, ag0aep6g wrote:
> On 04.05.2016 07:27, tsbockman wrote:
>> Without any redundancy in the syntax, minor corruption of the 
>> code could
>> easily result in a program that still "works" - that is, 
>> compiles and
>> runs without producing an error message - but whose behaviour 
>> has subtly
>> changed. With redundant syntax, on the other hand, the 
>> compiler is more
>> likely to detect and pinpoint the problem immediately.
>
> D doesn't have that kind of redundancy either here.

Yes it does.

> For the compiler to catch errors, it would have to mind both 
> punctuation and whitespace.

No it doesn't.

> But whitespace is purely cosmetic in D. Programmers might be 
> alarmed when they see a mismatch, but the compiler doesn't care.

This is true, but D's grammar still has some redundancy in it, 
even when whitespace is collapsed.

In D, if a single curly brace goes missing, the braces will no 
longer balance and the lexer will complain. In Python, if a 
single tab goes missing, the result may well be a lexically and 
syntactically valid - but buggy - program.


More information about the Digitalmars-d mailing list