Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2002-11-17 12:22:20


----- Original Message -----
From: "Peter Dimov" <pdimov_at_[hidden]>

> From: "Thorsten Ottosen" <nesotto_at_[hidden]>
> > From: "Peter Dimov" <pdimov_at_[hidden]>
> > [nip]
> > > In general, it is recommended practice to always assert()
preconditions
> in
> > > client code, instead of relying on in-library asserts. First, the
> library
> > is
> > > not required to have asserts, and second, the earlier you catch
> > precondition
> > > violations, the better (call stacks aren't universally available).
> >
> > I don't get this. It's a poor library if it does not even check its own
> > preconditions
> > in eg. debug mode. Moreover, if you put the precondition in the library,
> you
> > take the burden away from the client; this is highly recommeded since it
> > encapsulates
> > commen code _one_ place, not O(n) places!
>
> Note that "recommended practice" in my statement above means "recommended
> for library users." When you say "highly recommended" you mean
"recommended
> for library writers."

Yes, but note that having both is less fortunate. Either we agree that
library writers check preconditions and then
clients don't or we agree that clients check preconditions and library
writers don't. One reason that C is such
a pain in the *** to use is because its the cliets responsibility to check
conditions , e.g.

int * i = malloc( sizeof( i ) );
assert( i );

Libraries should always check as much as possible.

regards

Thorsten, AAU


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk