Re: Optional "then" and "do"

new topic     » goto parent     » topic index » view thread      » older message » newer message

yuku wrote:
> 
> I made changes to the parser.e so that the keyword "then" and "do"
> is optional (if the coder wants that it is still accepted).
> 
> Reasons:
> 
> - Less typing
> 
> - Prevent mistakes of writing if <expr> do  and  for <expr> then
>   which I did a lot of times (Kat too)
> 
> If no real objection is made, I will commit it.

Though it has already been committed as I write this, I object.  The then
and do keywords serve a purpose.  Consider the following error (warning
C code ahead):

   while(1);
   {
      // do stuff
      goto foo;
   }
   foo:
   // do stuff

Note that the semi-colon after the while statement ends the loop.  So you
get an infinite loop.  This can be difficult to detect because you are drawn
to the brackets, and can miss the fact that the semi-colon makes an empty
statement become the body of the loop.

This is similar to the point Salix made.  While objections about having to
use shifts to get to certain symbols make some sense to me (I guess emacs
users don't mind this sort of thing) I think if you are really complaining 
about having to type 2 or 4 normal characters, you should go code in 
APL or something.

I don't think we should combine then and do, although that's a less bad
idea than making them optional.  The if-then ties are pretty strong, IMHO.
I think before we start making syntax optional, we should consider carefully
where that leads.  This is one reason why perl can be so difficult to
read:  There Is More Than One Way To Do It.

Matt

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu