Date: Tue, 30 Jul 1996 00:08:41 +0900 (JST) From: Michael Hancock <michaelh@cet.co.jp> To: David Greenman <dg@root.com> Cc: Poul-Henning Kamp <phk@critter.tfs.com>, hackers@FreeBSD.ORG Subject: Re: kernel assertions Message-ID: <Pine.SV4.3.93.960729234251.29370A-100000@parkplace.cet.co.jp> In-Reply-To: <199607291401.HAA26854@root.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 29 Jul 1996, David Greenman wrote: > >In our code: > > void > > foo(char *buf, int i > > { > > ASSERT(buf,("foo(%p, %d): buf is zero",buf,i)); > > ... > > } > > Blech. Macros are evil unless they actually do something real to improve > the code. Please, let's NOT adopt this practice. They can reduce conceptual pollution. A conscientious programmer might integrate various checks into code that is trying to do something else and as a side-effect makes the code more complicated for readers and even compiler optimizers. Assertions are the most under-rated software engineering tool I can think of. If you want more information, stringify the expression in the assertion failure message or add a description parameter. At least give us the benefit of the doubt and try applying this to some random sample of code to see the difference it makes. I can think of 3 types of programmers who don't use assertions: 1) The god who writes all the code with zero bugs and doesn't need assertions. 2) The conscientious defensive programmer who integrates a lot of code checks in his code. The code has lots of nested structures and is complicated to read. 3) The programmer who gives up on the writing the checks because it's hell. His code is probably the source of very hard to find bugs. Assertions are simple to use and let's you write code for the problem at hand. There's no question as to where the responsibilities of the caller or callee lie. Mike Hancock
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SV4.3.93.960729234251.29370A-100000>