From: Martin Klaiber <martinkl@zedat.fu-berlin.de>
Subject: Re: Error-names.
Date: Sun, 29 Feb 2004 22:57:16 +0100
Date: 2004-02-29T22:57:16+01:00 [thread overview]
Message-ID: <sq3ah1-h38.ln1@martinkl.dialup.fu-berlin.de> (raw)
In-Reply-To: 404243E5.376C42BB@sympatico.ca
David Marceau <davidmarceau@sympatico.ca> wrote:
> Martin Klaiber wrote:
>> David Marceau <davidmarceau@sympatico.ca> wrote:
>>> make sure when others is used it is logged somewhere.
>> Hm, sorry, I don't understand what you mean here.
> I just mean the reason you use "when others" in the first place is
> because it is an exception you never thought about when designing
> the component.
This is true and it shows the dilemma. When writing the code I don't
know which exceptions a real Ada-implementation might provide. But I
also must ensure all exceptions are handled to give the C-program a
chance to avoid a crash. So I use "when others" at last.
Is there a way to find out which exceptions an implementation provides?
Ok, I have the types mentioned in the ARM but the implementation could
add some more.
> You have to admit when this happens whatever happens in a "when
> others" you have to document and figure out in what context the
> situation occurred in order to go back and add more code and maybe a
> new exception type to raise :)
That's right. Tracking down an error is more difficult then.
> The best way is to first catch it into a file in order to come back and
> read about it...hence logging the "when others" exception. I think you
> already understand this kind of thing but I voiced it out anyways just
> in case. A perfect application should not ever get into the part of
> the code inside "when others" at run-time. That said "when others" has
> to exist to catch a real exception and log the real exception to enable
> us programmers to analyze what the problem is later to be able to fix
> it ASAP. That's my opinion. Please correct me if I'm wrong.
No, you're right. But I want to avoid to implement file-I/O to keep
the lib as platform- and compiler-independent as possible. Perhaps I
implement a function, which allows the calling C-program to recall the
last error-message. This could be used for a bug-report then.
> Ada Exceptions and C Exceptions don't seem to use the same default
> cleanup strategies so you have to be very careful.
What do you mean by C Exceptions? Can C handle exceptions?
> As you stated in a C program returning a constant value for the error is
> standard "C" practice.
> From what I understand, returning nothing and placing valuable information in an
> "in out" parameter is more Ada95.
> The valuable information I talking about is an object holding a structure of a
> bunch of structures.
Ok, but complex types might give problems with the representation.
I also wanted to use records/structs for the interface first, instead
of the many set- and get-procedures/-functions. But people told me
that a C-program compiled with a different compiler than the compiler
used for the Ada-lib doesn't necessarily represent the types in the
same way. So I only use the C-types "int" and "long" now. This makes
it more simple and hopefully more robust.
> Also notice one line for the opening brace/parentheses and another line for
> closing brace/parentheses. Call me crazy but I think it is most legible this
> way. It also helps you do focus on one problem at a time for each line. I
> follow the same style for if statements and everything else. Sure it takes a
> bit more time but in the long run it's better in my humble opinion.
It think this is very individual preferences and cannot be answered
generally. So I wouldn't puzzle myself with it. Preferences also
change with time. I use more underscores now. Before I found the
code without underscores more legible, now it's the other way round.
Martin
next prev parent reply other threads:[~2004-02-29 21:57 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-28 12:58 Error-names Martin Klaiber
2004-02-28 13:35 ` Error-names Martin Dowie
2004-02-28 15:26 ` Error-names Martin Klaiber
2004-02-28 17:19 ` Error-names Marius Amado Alves
2004-02-28 18:31 ` Error-names Martin Klaiber
2004-02-28 19:47 ` Error-names tmoran
2004-02-28 20:29 ` Error-names Martin Klaiber
2004-02-29 19:03 ` Error-names Jeffrey Carter
2004-02-29 20:04 ` Error-names tmoran
2004-02-29 23:24 ` Error-names Björn Persson
2004-03-01 11:29 ` Error-names Martin Klaiber
2004-03-01 12:48 ` Error-names Marius Amado Alves
2004-03-02 2:15 ` Error-names Jeffrey Carter
2004-02-29 20:33 ` Error-names Martin Klaiber
2004-02-29 23:43 ` Error-names tmoran
2004-03-01 11:20 ` Error-names Martin Klaiber
2004-03-07 15:10 ` Error-names Björn Persson
2004-03-08 5:42 ` Error-names Dave Thompson
2004-02-28 20:26 ` Error-names Jacob Sparre Andersen
2004-02-28 18:29 ` Error-names Alexandre E. Kopilovitch
2004-02-29 5:30 ` Error-names David Marceau
2004-02-29 12:17 ` Error-names Martin Klaiber
2004-02-29 19:56 ` Error-names David Marceau
2004-02-29 21:57 ` Martin Klaiber [this message]
2004-03-01 23:20 ` Error-names Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox