From: nobody@REPLAY.COM (Anonymous)
Subject: Re: Building blocks (Was: Design By Contract)
Date: 1997/09/25
Date: 1997-09-25T00:00:00+00:00 [thread overview]
Message-ID: <199709251320.PAA03585@basement.replay.com> (raw)
In-Reply-To: 342A0AC6.2F2F@dynamite.com.au
<5v34m5$pl9$1@trumpet.uni-mannheim.de>
<wihnDCAGPDI0IwlD@treetop.demon.co.uk> <34215E3D.77AE@gsfc.nasa.gov>
<3421E190.49CC@chimu.com> <EGrz21.GoG@world.std.com>
<3423BE13.9C3852A4@munich.netsurf.de>
On Wed, 24 Sep 1997 23:55:02 -0700, Alan E & Carmel J Brain
<aebrain@dynamite.com.au> wrote:
>[...]
> If you want to resume, or retry, or whatever, you need to confine the
> exception to it's own block. A typical example looks something like:
>
> (Declarations, Constants omitted for simplicity)
>
> UnTransmitted := true;
> ReTryCounter := 0;
>
> while UnTransmitted loop
>
> if ReTryCounter > MaxRetries then
> raise LineContinuouslyBusy; end if; -- Line Too busy
> -- Report this upwards
> Transmission_Attempt_Block :
> begin
>
> Ethernet.TryToTransmit;
> UnTransmitted := false; -- Successful Transmission
>
> exception
> when Ethernet.LINE_BUSY =>
> ReTryCounter := ReTryCounter+1; -- Try again
> -- Note that this 'handles'
> -- the exception
> when Ethernet.NACK =>
> Untransmitted := false; -- Ignore Negative Ack.
> -- Again, exception handled.
> when others => raise;
> -- something unexpected and Nasty, Propagate it out!
>
> end Transmission_Attempt_Block;
>
> end loop;
>
This doesn't seem typical to me. It differs from typical in
1. Using mixed-case identifiers instead of underline-separated
identifiers (ReTryCounter instead of Re_Try_Counter).
2. Using while instead of loop/exit (ref. Ichbiah, Barnes, & Firth, "Ada
Launch," 1980 Dec 10, videotape, on why while was included in the
language).
3. The design of Ethernet is faulty, since it uses exceptions for
non-exceptional circumstances (line busy, NACK received).
4. Unusual formatting of the if.
If we have to use Ethernet as is, I'd say the following is more typical
Retry_Counter := 0;
Send : loop
if Retry_Counter > Max_Retries then
raise Line_Continuously_Busy;
end if; -- Line too busy; report this upwards
Try_One : begin
Ethernet.Try_To_Transmit;
exit Send; -- Successful transmission
exception -- Try_One
when Ethernet.Line_Busy =>
Retry_Counter := Retry_Counter + 1; -- Try again
when Ethernet.Nack =>
exit Send; -- Accept NACK as success
end Try_One;
end loop Send;
Jeff Carter PGP:1024/440FBE21
My real e-mail address: ( carter @ innocon . com )
"You brightly-colored, mealy-templed, cranberry-smelling, electric
donkey-bottom biters."
Monty Python & the Holy Grail
Posted with Spam Hater - see
http://www.compulink.co.uk/~net-services/spam/
next prev parent reply other threads:[~1997-09-25 0:00 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-09-09 0:00 Building blocks (Was: Design By Contract) Marc Wachowitz
1997-09-15 0:00 ` Joachim Durchholz
1997-09-17 0:00 ` Paul Johnson
1997-09-18 0:00 ` Stephen Leake
1997-09-18 0:00 ` Mark L. Fussell
[not found] ` <11861963wnr@eiffel.demon.co.uk>
1997-09-19 0:00 ` Mark L. Fussell
1997-09-19 0:00 ` Robert A Duff
1997-09-20 0:00 ` Joachim Durchholz
1997-09-22 0:00 ` Matthew Heaney
1997-09-23 0:00 ` Joachim Durchholz
1997-09-23 0:00 ` Veli-Pekka Nousiainen
1997-10-03 0:00 ` Robert I. Eachus
1997-10-04 0:00 ` Paul Johnson
1997-10-14 0:00 ` Robert I. Eachus
1997-09-23 0:00 ` Jon S Anthony
1997-09-24 0:00 ` Richard A. O'Keefe
1997-09-24 0:00 ` Alan E & Carmel J Brain
1997-09-25 0:00 ` Anonymous [this message]
1997-09-30 0:00 ` Alan E & Carmel J Brain
1997-09-30 0:00 ` Matthew Heaney
1997-09-30 0:00 ` W. Wesley Groleau x4923
1997-09-30 0:00 ` Matthew Heaney
1997-10-01 0:00 ` Alan E & Carmel J Brain
1997-09-30 0:00 ` Neil Wilson
1997-09-30 0:00 ` Stephen Leake
1997-10-01 0:00 ` Anonymous
1997-10-01 0:00 ` Paul M Gover
1997-10-04 0:00 ` Paul Johnson
1997-10-04 0:00 ` Matthew Heaney
1997-10-15 0:00 ` Paul Johnson
1997-10-15 0:00 ` Matthew Heaney
1997-10-16 0:00 ` Joachim Durchholz
1997-10-17 0:00 ` Robert I. Eachus
1997-10-16 0:00 ` Joachim Durchholz
1997-10-22 0:00 ` Reimer Behrends
1997-10-01 0:00 ` Joachim Durchholz
1997-10-02 0:00 ` Robert A Duff
1997-10-02 0:00 ` Tucker Taft
1997-10-02 0:00 ` Matthew Heaney
1997-10-03 0:00 ` Stephen Leake
1997-10-04 0:00 ` Matthew Heaney
1997-10-07 0:00 ` Robert A Duff
1997-09-19 0:00 ` Jon S Anthony
1997-09-23 0:00 ` Mark L. Fussell
1997-09-18 0:00 ` W. Wesley Groleau x4923
1997-09-21 0:00 ` Matthew Heaney
1997-09-18 0:00 ` Jon S Anthony
1997-09-18 0:00 ` Robert Dewar
-- strict thread matches above, loose matches on Subject: below --
1997-09-11 0:00 Robert Dewar
1997-09-09 0:00 Marc Wachowitz
1997-09-02 0:00 Design By Contract Jon S Anthony
[not found] ` <JSA.97Sep3201329@alexandria.organon.com>
1997-09-04 0:00 ` Paul Johnson
[not found] ` <5un58u$9ih$1@gonzo.sun3.iaf.nl>
1997-09-06 0:00 ` Building blocks (Was: Design By Contract) Joachim Durchholz
1997-09-08 0:00 ` Paul Johnson
1997-09-08 0:00 ` Brian Rogoff
1997-09-09 0:00 ` Matthew Heaney
1997-09-09 0:00 ` W. Wesley Groleau x4923
1997-09-10 0:00 ` Robert A Duff
1997-09-12 0:00 ` Jon S Anthony
1997-09-09 0:00 ` Brian Rogoff
1997-09-10 0:00 ` Paul Johnson
1997-09-10 0:00 ` Matthew Heaney
1997-09-10 0:00 ` Darren New
1997-09-10 0:00 ` Robert Dewar
1997-09-12 0:00 ` Jon S Anthony
1997-09-12 0:00 ` Robert Dewar
1997-09-16 0:00 ` Brian Rogoff
1997-09-12 0:00 ` Paul Johnson
1997-09-14 0:00 ` Robert Dewar
1997-09-15 0:00 ` John G. Volan
1997-09-14 0:00 ` Robert Dewar
1997-09-14 0:00 ` Robert Dewar
1997-09-09 0:00 ` W. Wesley Groleau x4923
1997-09-09 0:00 ` Veli-Pekka Nousiainen
1997-09-09 0:00 ` Jon S Anthony
1997-09-09 0:00 ` Veli-Pekka Nousiainen
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox