Proposal of a general do-while loop
Tristam MacDonald
swiftcoder at gmail.com
Tue Jul 17 13:41:48 PDT 2007
The point I was trying to make is that while any thing *can* be done through tricky code, the do {} while {} is such a common problem that I agree with the OP that it *should* have a distinct syntactical representation.
Intoducing such a basic syntax element to C/C++ at this stage would be nigh impossible, but D is young enough to adopt something like this, and something which simplifies syntax and readability is IMHO worth considering.
BCS Wrote:
> Reply to Tristam,
>
> > While we are at it, why not just this?
> >
> > goto mid;
> > begin:
> > cc;
> > mid:
> > aa;
> > if (bb) goto begin;
> > Clear concise and simple, plus it is much closer to the actual machine
> > logic, and so may imrpove performance as much as -1% ;)
> >
>
> While your point is relevant, the actual reason for doing it the way I pointed
> out is not performance, but the removal of duplicate source code. I am a
> firm believer in the assertion that anytime you have duplication of code[*],
> you have a bug waiting to happen.
>
> Except for the goto, my example read reasonably clearly and does a reasonable
> job of describing what is intended. The original proposal and the other examples
> (except maybe the if()break; example) are not, IMHO, so clear. If you can
> think of a better way to show the intent, I'm interested.
>
> *IIRC the XP folks will agree with me, however I'm only looking at code that
> is /exactly/ the same, not just abstractable to the same thing.
>
>
More information about the Digitalmars-d
mailing list