comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison <dennison@telepath.com>
Subject: Re: How to implement a continue statement in Ada?
Date: 2000/02/09
Date: 2000-02-09T00:00:00+00:00	[thread overview]
Message-ID: <87s92d$lj1$1@nnrp1.deja.com> (raw)
In-Reply-To: m3ya8v1g93.fsf@skinner.demon.co.uk

In article <m3ya8v1g93.fsf@skinner.demon.co.uk>,
  Aidan Skinner <aidan@skinner.demon.co.uk> wrote:
> I would expect this case to be picked up by the compiler, without the
> need for an explicit goto. Was there a reason why the appropriate
> section of code couldn't be put into a (possibly nested) procedure and
> recurse itself?

That does raise a good issue. Often when this comes up I will fudge it
by putting the code in the loop inside of a subroutine, from which I can
simulate continue with a "return". This could also be done with an
"exit" statement by putting the code in another loop that has an "exit;"
at the end. But that looks silly, while the subroutine often makes some
sense in and of itself.

Given that such workarounds (hacks) exist, why not put continue
capability in Ada 0X by allowing the "exit" statement to exit outside of
a begin..end block? The fact that you can't do this is actually a common
confusion for newbies anyway.

I'll admit its a bit "heavy" of a solution, since it involves another
level of nesting. But it has some advantages to offset that. The
existence of the block would tip readers off that a early termination
may exist. Also, this is more powerful that a meer "continue", because
you can explicitly specify the scope of the statements that get skipped.
For instance, you could have some extra code outside of the block at the
end of the loop that does not get skipped.

--
T.E.D.

http://www.telepath.com/~dennison/Ted/TED.html


Sent via Deja.com http://www.deja.com/
Before you buy.




  parent reply	other threads:[~2000-02-09  0:00 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-02-08  0:00 How to implement a continue statement in Ada? Oliver Kellogg
2000-02-08  0:00 ` Ted Dennison
2000-02-09  0:00   ` Roger Barnett
2000-02-08  0:00 ` David Starner
2000-02-08  0:00   ` Aidan Skinner
2000-02-09  0:00     ` David Starner
2000-02-10  0:00       ` Aidan Skinner
2000-02-12  0:00       ` Character vs. String comparisons (was: Re: How to implement a continue statement in Ada?) Jeff Carter
2000-02-12  0:00         ` David Starner
2000-02-09  0:00     ` Ted Dennison [this message]
2000-02-12  0:00       ` How to implement a continue statement in Ada? Jeff Carter
2000-02-14  0:00       ` Oliver Kellogg
  -- strict thread matches above, loose matches on Subject: below --
1998-08-31  0:00 Robert T. Sagris
1998-09-01  0:00 ` Dr Richard A. O'Keefe
1998-09-01  0:00   ` dewarr
1998-09-03  0:00     ` Dr Richard A. O'Keefe
1998-09-03  0:00       ` dennison
1998-09-01  0:00 ` dewarr
     [not found] <35EA8153.7BFC91E3@physics.purdue.edu>
1998-08-31  0:00 ` Robert I. Eachus
1998-08-31  0:00   ` Robert T. Sagris
1998-09-01  0:00     ` Matthew Heaney
1998-08-31  0:00 ` Norman H. Cohen
1998-09-01  0:00 ` alan walkington
1998-09-02  0:00   ` Dr Richard A. O'Keefe
1998-09-02  0:00     ` alan walkington
1998-09-02  0:00     ` Matthew Heaney
1998-09-03  0:00     ` dewarr
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox