From: | tm <thomas.mertes@gmx.at> |
Newsgroups: | comp.compilers |
Date: | Thu, 17 Feb 2011 05:30:05 -0800 (PST) |
Organization: | Compilers Central |
References: | 11-01-043 11-02-011 |
Keywords: | syntax, design |
Posted-Date: | 18 Feb 2011 23:45:28 EST |
On 13 Feb., 16:43, 1Z <pdjpurch...@googlemail.com> wrote:
> On Jan 13, 6:09 pm, noitalmost <noitalm...@cox.net> wrote:
>
> > I've noticed that Wirth has continually rejected the idea of a break
> > statement and I was wonder why. Is this purely philosophical, or are
> > there code optimization reasons? Naive code for a break is trivial to
> > implement.
>
> > Is it easier to optimize loops with no break? That is, is the cost of
> > having extra booleans to control the loop less than the cost of
> > messing up the basic blocks with break?
> > [It's a little easy to optimize single-exit loops, but my impression is
> > that the motivation was more like salvation through suffering. -John]
>
> A compromise would be to allow only one "middle exit" per loop, and
> to have it clearly indicated in the syntax rather than looking like
> any old statement.
I defined such a loop with middle exit as example for Seed7.
It could be used like
loop
ch := getc(inFile);
until ch = '\n' do
stri &:= str(ch);
end loop;
The meaning of the loop above is the same as
repeat
ch := getc(inFile);
if ch <> '\n' then
stri &:= str(ch);
end if;
until ch = '\n';
Details of the Seed7 loop with middle exit can be found here:
http://seed7.sourceforge.net/manual/syntax.htm#The_syntax_of_a_statement
Greetings Thomas Mertes
--
Seed7 Homepage: http://seed7.sourceforge.net
Seed7 - The extensible programming language: User defined statements
and operators, abstract data types, templates without special
syntax, OO with interfaces and multiple dispatch, statically typed,
interpreted or compiled, portable, runs under linux/unix/windows.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.