| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | pdgoal.txt 1/ |
PM>> The C++ way with exception would be
PM>> try
PM>> {
PM>> func1();
PM>> func2();
PM>> func3();
PM>> }
PE> I was thinking about something like this for C programs too, and my
PE> current thoughts are to do this:
PE> #define CC if (!ALLOK) break;
PE> do {
PE> func1(); CC
PE> func2(); CC
PE> func3(); CC
PE> } while (0);
Having the CC at the end of the line could make it easy to miss while
reading the code. It would also be easy to forget to put it in. You could
try something like:
#define try(x) x;if (!ALLOK) break;
do
{
try(func1());
try(func2());
try(func3());
}
while(0);
This method will have problems when you have code like:
do
{
try(func());
if (something)
{
do
{
try(func2());
try(func3());
}
while(0)
}
try(func4());
}
while(0);
if an error is detected in func2() or func3() then you are still going to
execute func4().
Of course, what you're really doing here is using the do...while as a goto.
Using a goto the code could then be:
#define try(x, y) x;if (!ALLOK) goto y;
try(func(), error);
if (something)
{
try(func2(), error);
try(func3(), error);
}
try(func4(), error);
return;
error:
error handling code
Paul
--- GoldED/2 2.42.G1114
* Origin: It's life Jim, but not as we know it (3:711/934.1)SEEN-BY: 635/514 640/305 711/809 934 @PATH: 711/934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.