Semicolons: mostly unnecessary?

Nick Sabalausky a at a.a
Wed Oct 21 22:02:33 PDT 2009


"AJ" <aj at nospam.net> wrote in message news:hbo2up$2pb5$1 at digitalmars.com...
>
> "Adam D. Ruppe" <destructionator at gmail.com> wrote in message 
> news:mailman.222.1256163114.20261.digitalmars-d at puremagic.com...
>> On Wed, Oct 21, 2009 at 05:05:04PM -0500, AJ wrote:
>>> Why not eliminate the requirement for semicolon statement terminators
>>> (unless there are multiple statements per line)? Less typing is "more"!
>>
>> It looks wrong, breaks habit, opens up bizarre parsing corner cases,
>> and makes error messages uglier.
>>
>> Next thing you know someone will propose eliminating braces and just
>> using whitespace to denote blocks. It's utter madness.
>
> Not "whitespace aware", but rather "newline aware". "Newlines" are already 
> at the end of a line, so a semicolon is redundant. IOW, the default 
> statement terminator can be the newline.
>
> struct something
> {
>    int x1
>    long x2
> }
>
> vs.
>
> struct something
> {
>    int x1;
>    long x2;
> };
>
> First one is definitely "cleaner". The less the eye has to bring in to be 
> deciphered by the brain, the better.
>
> void somefunc()
>
> Is the above a declaration or start of a definition? Still though, only 1 
> char of lookahead needed to determine.
>
> Maybe one can't fully appreciate semicolon terminators until one tries to 
> implement a language without them. (Because apparently no one has written 
> that article or paper (?)).

I've spent a lot of time with languages that use EOL as a statement 
terminator (along with the special line-continuation token that approach 
necessitates), and I've found editing code in those languages to be a royal 
pain in the ass.

Also, referring to your second struct example above, D never has semicolons 
directly after a closing curly-brace.





More information about the Digitalmars-d mailing list