Re: [gtk-list] Re: rfc: exceptions (code included)
- From: "David Given" <dg tao-group com>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: rfc: exceptions (code included)
- Date: Thu, 30 Sep 1999 17:42:03 +0100
[...]
>> So you'll find my exception code attached to this mail (it's about 2k
>> compressed, so I am sending this in), any comments, suggestions welcome. I
>> would be very glad seeing it included in glib.
>
>At first glance this looks rather useable, does it behave like C++
>exceptions? IMHO this should be included in GLIB.
[...]
I've just found this:
http://home.rochester.rr.com/bigbyofrocny/GEF.html
It seems to be a fully-fledged exception and contract programming system for
C. Here's some example code:
gef_try {
number = atof(argv[1]);
answer = SquareRoot(number);
printf("%.2f\n", answer);
} gef_preconditions {
gef_assert(argc == 2);
} gef_catch(exception) {
switch((int) exception) {
case EXCEPT_ARITHMETIC_VIOLATION:
fprintf(stderr, "%s: Cannot take square root of %f!\n", argv[0],
number);
exitCode = 1;
gef_break;
case EXCEPT_ALARM_EXPIRED:
fprintf(stderr, "\n%s: Times up!\n", argv[0]);
exitCode = 1;
gef_break;
case EXCEPT_ASSERTION_VIOLATION:
fprintf(stderr, "%s: Assertion violation!\n", argv[0]);
exitCode = 1;
gef_break;
case EXCEPT_INTERRUPTION:
fprintf(stderr, "\n%s: Program interrupted!\n", argv[0]);
exitCode = 1;
gef_break;
default: break;
}
} gef_end;
I've never used it, but the author claims it's well-tested and stable. It's
rather heavyweight, you have to set up the exception system before you can use
it. It also supports multiple threads.
I've also got saved away a much lighter-weight exception system of the same
sort of thing, written by Alan Insley. No example code, unfortunately.
Anybody interested in either of these?
--
+- David Given ---------------McQ-+ "There does not now, nor will there ever,
| Work: dg@tao-group.com | exist a programming language in which it is
| Play: dgiven@iname.com | the least bit hard to write bad programs."
+- http://wired.st-and.ac.uk/~dg -+ --- Flon's Axiom
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]