suggested improvements to D

Warren D Smith wds at math.temple.edu
Tue Jan 9 10:32:09 PST 2007


reply to BCS's reply

actually you meant this:
loop: do{
  for(some loop condition){
    if(something) break loop;
  }
  fallthru_code;
}while(false);
break_out_code;

which I agree solves my problem without gotos, but at the cost of ugliness.  So I
guess the best solution is if a less-ugly way were supported to do this same thing.
We could have a DoItOnce{ ... }  pseudo-loop (which never loops)
syntax to replace do{ ... }while(false);  but that still is ugly.
So your suggestion for this syntax is a good one:

bod: {     // labeled compound statement
   if(cond) break bod;
}

except I do not see the point (or syntactical meaning,
for that matter) of having "continue bod" if bod is not
manifestly a loop.   This simple suggestion of being
able to break out of any block, would
eliminate practically all the remaining gotos in the world.
Excellent idea.



More information about the Digitalmars-d mailing list