[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: assert() vs. return(error)

From: Branko Čibej <brane_at_xbc.nu>
Date: 2006-02-16 03:17:02 CET

Christian Stork wrote:
> Assertions are defined by their use. Normally, that means that they act
> as run-time aborts in the debugging version when the asserted condition
> isn't met. The shipped version of the code is compiled without
> assertions.
>
> Implications of this definition:
>
> - assertions act as checked documentation
> - assertions should not have side-effects
> - assertions don't need to be very efficient
>
> It seems that subversion and others would like to have something like
> checked documentation combined with a conditional abort and use assert()
> for that. Maybe a different name like require() would be a better
> choice, since it prevents confusion with the intended usage of C's
> assert().
>
> The folklore argument in favor of assertions over documentation is, IIRC:
> "Assertions catch the error as early as possible." I might add
> "...while debugging."
>
I really can't agree about the "while debugging" bit. IMNSHO
"development" and "release" versions should behave identically,
otherwise you have to do all your QA twice. Furthermore it's quite
likely that a bug reported against the release version can't be
reproduced in the debug version.

This debug- vs. release-mode dichotomy comes from the commercial world
and its paranoia about reverse engineering. Here, we *like* reverse
engineering.

-- Brane

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Feb 20 08:40:37 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.