[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Avr-libc-corelib] Error handling
From: |
Ruud Vlaming |
Subject: |
Re: [Avr-libc-corelib] Error handling |
Date: |
Tue, 22 Sep 2009 00:52:02 +0200 |
User-agent: |
KMail/1.9.1 |
On Monday 21 September 2009 23:27, Jan Waclawek wrote:
> A common thing to do is to return an error flag if a function fails to
> perform as intended.....
Although common, i usually find it a waste of the costly return variable,
which, as you
correcty point out is usually ignored. (If that is wise is an other matter ... )
> Ergo, IMHO it's a pure waste to return runtime error codes, and I suggest to
> establish a single variable,
> core_lib_error or such, where functions could store an appropriate code when
> error occurs, and
> leave it upon the user how does he wish to use or ignore it.
Allthough i agree that mostly error codes are a waste (if they do not provide
specific information)
i strongly oppose the use of a single error variable. This makes concurrent use
of the library
virtually impossible. Lets make all code reentrant, or at least up to the point
where
the hardware dictates otherwise.
But i think we don't have 'errors' in the classical way. An 'error' is a
situation that the called
function cannot handle. But i would say, that should not happen, or at least,
since our
state space of the functions is usually very small, the 'error' should be a
natural part
of the returned information, thus, no generic error handling.
Ruud.