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

richard@cogsci.ed.ac.uk (Richard Tobin)
Wed, 19 Jan 2011 14:51:16 +0000 (UTC)

          From comp.compilers

Related articles
[3 earlier articles]
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)
Re: are there implementation reasons for not providing a break stateme idbaxter@semdesigns.com (Ira Baxter) (2011-03-07)
Re: are there implementation reasons for not providing a break stateme gah@ugcs.caltech.edu (glen herrmannsfeldt) (2011-03-08)
Re: are there implementation reasons for not providing a break stateme robin51@dodo.com.au (robin) (2011-03-11)
| List of all articles for this month |

From: richard@cogsci.ed.ac.uk (Richard Tobin)
Newsgroups: comp.compilers
Date: Wed, 19 Jan 2011 14:51:16 +0000 (UTC)
Organization: HCRC, University of Edinburgh
References: 11-01-043 11-01-055 11-01-078 11-01-081
Keywords: syntax, optimize
Posted-Date: 19 Jan 2011 11:04:08 EST

August Karlstrom <fusionfile@gmail.com> wrote:


>> while(condition) {
>> pre;
>> if(something)
>> break;
>> post;
>> }


>If your pre and post statements refer to a loop invariant the
>precondition should be checked before the loop is entered and the
>postcondition should be unconditionally checked at the end of each
>turn.


No, they were just the statements before and after the break.


>With a "structured" ("goto-less") loop a human only have to look at
>the loop guard rather than skimming through all of its contained
>statements in order to know what will hold true when the loop is
>finished (if it ever finishes that is). To me that is an obvious
>advantage.


But the loop condition may be more complicated as a result of having
avoided the break. And knowing under what condition a loop is
finished is not the only thing a reader is concerned about. The
resulting unnaturalness of the loop body may outweigh that.


And of course, you don't have to use breaks and gotos even if
the language provides them.


-- Richard



Post a followup to this message

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