Semicolons: mostly unnecessary?

AJ aj at nospam.net
Wed Oct 21 21:29:07 PDT 2009


"Adam D. Ruppe" <destructionator at gmail.com> wrote in message 
news:mailman.228.1256181155.20261.digitalmars-d at puremagic.com...
> On Wed, Oct 21, 2009 at 09:25:34PM -0500, AJ wrote:
>> That's not D source code. Why do you keep trying to use English text as 
>> an
>> example?
>
> The logic behind all the arguments you make,

That would be "all fine and dandy", but I'm not arguing about anything. (So 
you must be arguing? About what?).

> except for one, should apply
> equally well to English as it does to D.

That's silly. There is no need to use the text of Shakespeare's tragedies to 
allude to source code. There is no need and it is entirely inappropriate to 
expand the context of the issue to other realms. The context is (currently): 
semicolons as statement terminators for single-statement lines.

>
> Cons:
>
> 1. Makes source code less comprehensible.
>
> Based on what? Because you say so?

It's more to digest when it's not necessary. It's easier to identify 
something when it's in less intricate (read, plain) surroundings.

<snipped inappropriate context reference>


> 2. Is redundant with the newline designator.
>
<snipped inappropriate context reference>

> is obviously false,

If I put it on the list, it wasn't obvious at all, even if it is incorrect 
(though I think it is correct).

> unless
> you specifically require a line continuation character:
>
> a = b +
> c

Without semicolon requirement:

a=b+ // this is an error
c // this is OK

With semicolon requirement:

a=b+; // this is an error
c; // this is OK

What's the diff?

> A newline and a semicolon are not redundant unless you specifically define
> a statement as being one and only one line.

A semicolon is redundate with newline for single-statement lines. Oh, you 
say that a lot of constructs are inherently single statements but written on 
multiple lines? Well, that may be just the kind of examination I was looking 
for (ironic that _I_ had to bring it up, huh):

if(true)
    dothis()

That situation has to be evaluated: is parsing at the construct level too 
much effort or is it desireable? (ParseIfStatement()). Statement-level 
parsing better/worse than line-level parsing?

> Back to the magic of above though. What if you rewrote it:
> a = b
>    +c

Without semicolon requirement:

a=b // OK
 +c // error

With semicolon requirement:

a=b; // OK
 +c; // error

What's the diff?

> 3. Is more typing.
>
<snipped inappropriate context reference>>

>  how long does it take to type a semicolon anyway?

Typing unnecessary semicolons (if they are unnecessary) is "dumb".





More information about the Digitalmars-d mailing list