You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Daniel Berlin <db...@dberlin.org> on 2006/02/14 04:20:31 UTC

Re: assert() vs. return(error) [was: problem revealed by issue #2398 (server-side assertion)]

On Tue, 2006-02-14 at 03:51 +0000, Julian Foad wrote:
> Let's try to keep this discussion about the use of assertions separate from the 
> thread about one particular instance.  To that end, I've changed the Subject 
> line.  (You should delete the "[was:...]" part when replying.)
> 
> The debate on the relative merits and appropriate usage of assert vs. error 
> return is tricky.  We had a conversation about it a year or two ago which 
> didn't go far.  There is a lot to learn.  Our use of assert() is definitely 
> patchy and inconsistent.
> 
> Rather than debate this from scratch, there must be words of wisdom already 
> written that we can go and read to become familiar with the main arguments and, 
> hopefully, recommendations.  Can we find some?  I spent the last two hours 
> searching and reading stuff on the web; the best I found so far is 
> <http://www.lenholgate.com/archives/000525.html> which is a long rambling 
> discussion mainly about disadvantages of assert, hardly addressing server 
> software at all, and focused on C++ exceptions as the main alternative.  I'm 
> sure someone can find a better on-line source of wisdom...
> 
> URLs please.  Then we can discuss the issue knowledgeably.

It's hard to find URL's.

The use of assert in server applications, is of course, a topic of
debate anyway :).

The basic rule I've seen in server apps (which is not applicable to
client at all) is that if your caller could do something sensible in the
face of an error, to return an error.

This means that almost all cases in server apps should be returning
errors, not making asserts.


--Dan




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org