Re: are there implementation reasons for not providing a break statement in an imperative language?

richard@cogsci.ed.ac.uk (Richard Tobin)
Tue, 18 Jan 2011 14:54:48 +0000 (UTC)

          From comp.compilers

Related articles
are there implementation reasons for not providing a break statement i noitalmost@cox.net (noitalmost) (2011-01-13)
Re: are there implementation reasons for not providing a break stateme DrDiettrich1@aol.com (Hans-Peter Diettrich) (2011-01-14)
Re: are there implementation reasons for not providing a break stateme fusionfile@gmail.com (August Karlstrom) (2011-01-14)
Re: are there implementation reasons for not providing a break stateme anton@mips.complang.tuwien.ac.at (2011-01-15)
Re: are there implementation reasons for not providing a break stateme bc@freeuk.com (BartC) (2011-01-16)
Re: are there implementation reasons for not providing a break stateme Pidgeot18@verizon.net (Joshua Cranmer) (2011-01-16)
Re: are there implementation reasons for not providing a break stateme richard@cogsci.ed.ac.uk (2011-01-18)
Re: are there implementation reasons for not providing a break stateme fusionfile@gmail.com (August Karlstrom) (2011-01-18)
Re: are there implementation reasons for not providing a break stateme fusionfile@gmail.com (August Karlstrom) (2011-01-18)
Re: are there implementation reasons for not providing a break stateme richard@cogsci.ed.ac.uk (2011-01-19)
Re: are there implementation reasons for not providing a break stateme bc@freeuk.com (Bartc) (2011-01-20)
Re: are there implementation reasons for not providing a break stateme pdjpurchase@googlemail.com (1Z) (2011-02-13)
Re: are there implementation reasons for not providing a break stateme thomas.mertes@gmx.at (tm) (2011-02-17)
[3 later articles]
| List of all articles for this month |

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


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.