Topic: new C++ keyword 'retry
Author: jln2@cec2.wustl.edu (Sammy D.)
Date: Sat, 4 Sep 1993 16:03:24 GMT Raw View
how about this:
#define retry continue
as in:
while(1) {
...
if (!ok) retry;
...
break;
}
Author: mdu@abacus.be (Marc Duponcheel)
Date: Tue, 31 Aug 1993 14:17:43 GMT Raw View
In article <15169@uqcspe.cs.uq.oz.au> dated 31 Aug 93 03:37:08 GMT, Warwick Allison (warwick@cs.uq.oz.au) wrote:
: marc@offline.be (Marc Duponcheel) writes:
: #define TRY gumby: try
: #define RETRY goto gumby
I believe your macros will give problems
because of duplicate labels.
e.g.
the following code does not compile.
void f()
{
a:
{
a:
{
goto a;
}
goto a;
}
}
-- marc.
--
ABACUS consultants +32 (0)2 772.22.46
mdu@abacus.be (Marc Duponcheel)
Author: marc@offline.be (Marc Duponcheel)
Date: 28 Aug 93 18:39:25 PST Raw View
What about a new keyword 'retry' for C++ ?
At work I use the folowing code ...
The idea is to let the user try until the user gives up.
'request()', 'class denied' and 'choice()' are pseudo code here
In our particular case operations on database are requested and probably
denied because of multi user access constraints (database locks), however,
the user is offered the choice to try again or to give up.
==============================================================
HOW IT IS NOW
==============================================================
int retry = 1;
while(retry)
{
try
{
// user requests something !
request(something);
retry = 0;
}
catch(denied& d)
{
// user request denied ...
// let user decide to retry or cancel
retry = choice(d.Reason(), "retry", "cancel"))
}
}
==============================================================
HOW IT COULD BE (if retry was available)
==============================================================
try
{
// user requests something !
request(something);
}
catch(denied& d)
{
// user request denied ...
// let user decide to retry or cancel
if(choice(d.Reason(), "retry", "cancel")))
retry; // new C++ keyword
}
==============================================================
It seems to me that the implementation of such a 'retry' feature
is a very simple add-on to normal exception handling.
Any comments ?
-- marc.
################################################################################
email preferred address marc@offline.be [= me@home]
aka marc@offline.UUCP ub4b!offline!marc offline!marc
if [me@home] fails mdu@abacus.be [= me@brussels.work]
or mdp@cimad.be [= me@antwerp.work]
fido 2:292/603.26 Marc.Duponcheel@p26.f603.n292.z2.FidoNet.Org [= me@home]
bix mduponcheel mduponcheel@BIX.com [= me@home]
################################################################################
Author: rfg@netcom.com (Ronald F. Guilmette)
Date: Sun, 29 Aug 1993 18:00:27 GMT Raw View
In article <marc.05rf@offline.be> marc@offline.be (Marc Duponcheel) writes:
>
>What about a new keyword 'retry' for C++ ?
>
...
>==============================================================
> try
> {
> // user requests something !
> request(something);
> }
> catch(denied& d)
> {
> // user request denied ...
> // let user decide to retry or cancel
> if(choice(d.Reason(), "retry", "cancel")))
> retry; // new C++ keyword
> }
>==============================================================
Nobody detests gotos more than I do, but I'm not such a fanatic about them
that I refuse to use them when the situation warrants their use. Consider:
==============================================================
retry:
try
{
// user requests something !
request(something);
}
catch(denied& d)
{
// user request denied ...
// let user decide to retry or cancel
if(choice(d.Reason(), "retry", "cancel")))
goto retry; // Hey! You gotta do what you gotta do!
}
==============================================================
Summary: You don't need YANF (yet another new feature) to do what you want
to do in this case.
--
-- Ronald F. Guilmette ------------------------------------------------------
------ domain address: rfg@netcom.com ---------------------------------------
------ uucp address: ...!uunet!netcom.com!rfg -------------------------------
Author: warwick@cs.uq.oz.au (Warwick Allison)
Date: 31 Aug 93 03:37:08 GMT Raw View
marc@offline.be (Marc Duponcheel) writes:
>What about a new keyword 'retry' for C++ ?
#define TRY gumby: try
#define RETRY goto gumby
If your "retry" idea gets added to C++, all your code using your current
method (with "retry" as an identifier) is going to break.
--
Warwick