From: | "Bartc" <bc@freeuk.com> |
Newsgroups: | comp.compilers |
Date: | Thu, 20 Jan 2011 16:28:00 -0000 |
Organization: | A noiseless patient Spider |
References: | 11-01-043 11-01-055 11-01-078 |
Keywords: | syntax, design, optimize |
Posted-Date: | 21 Jan 2011 22:10:59 EST |
"Richard Tobin" <richard@cogsci.ed.ac.uk> wrote in message
> 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.
(I admit I know nothing about proving correctness of programs. How
exactly do you go about it? Who or what is to judge whether a program
is correct; is there some sort of specification to compare against?
And if so, how do you know the specification is correct...?)
> 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;
> }
This is trivial if the conditional break statement is at the top
level. If the breaks are deeper down then it's not so simple.
--
Bartc
Return to the
comp.compilers page.
Search the
comp.compilers archives again.