From: | richard@cogsci.ed.ac.uk (Richard Tobin) |
Newsgroups: | comp.compilers |
Date: | Tue, 18 Jan 2011 14:54:48 +0000 (UTC) |
Organization: | HCRC, University of Edinburgh |
References: | 11-01-043 11-01-055 |
Keywords: | design, syntax |
Posted-Date: | 18 Jan 2011 10:25:29 EST |
In article 11-01-055,
August Karlstrom <fusionfile@gmail.com> wrote:
>With no break statements you will know that the loop condition will be
>false when the loop has finished. This makes it easier to reason about
>the correctness of a program.
A break can trivially be removed by a simple source transformation:
while(condition) {
pre;
if(something)
break;
post;
}
boolean stop = false;
while(!stop && condition) {
pre;
if(something)
stop = true;
if(!stop)
post;
}
Is this easier to reason about? Not for a computer: it could do the
transformation itself. A human doing certain particular kinds of
reasoning might find it easier, but a human just reading the program
is likely to find it less clear.
A programmer may be able to find a more natural alternative than the
one above, but even if he does the language has prevented him from
expressing his intention in the obvious way.
-- Richard
Return to the
comp.compilers page.
Search the
comp.compilers archives again.