Boost logo

Boost :

From: William Kempf (sirwillard_at_[hidden])
Date: 2000-07-31 16:48:18

--- In boost_at_[hidden], "David Abrahams" <abrahams_at_m...> wrote:
> ----- Original Message -----
> From: "William Kempf" <sirwillard_at_m...>
> To: <boost_at_[hidden]>
> Sent: Monday, July 31, 2000 10:08 AM
> Subject: [boost] Re: compile time asserts [preconditions]
> > I strongly suggest you pick a different name. Preconditions
> > have a very well known meaning, for which a compile time assert
> > not work. Specifically, a precondition is one of the three
> > components that build up the foundation of DBC (design by
> > precondition, postcondition and invariant. All of these are
> > assertions. A precondition is that that must be upheld before a
> > function can be called (aka it's what you must insure when you
call a
> > function).
> They're not completely unrelated: the compile-time assert is a very
> case of precondition, where the precondition can be checked by the

First, this is like saying that it's not unrelated to assert, which
is true, but obviously we won't call it assert. Second, it's not
really a precondition at all, compile time or otherwise. A
precondition is very specific in what it's asserting, or more
accurately, where it's asserting. A precondition is what needs to be
fullfilled before a function call can be made. These compile time
asserts are often used outside of this context.

> That said, I think the name "precondition" suffers the same problem
as many
> of the other names that we've seen: namely, that it looks like just
> way to write "assert". I am getting tired of listening to myself
nag y'all
> about this, but I insist that the name needs to contain some
indication that
> there is static checking going on:
> all work, with BOOST_STATIC_ASSERT being my favorite so far.

I agree with this totally. The word "static" is overused, but most
of us can easily understand its meaning in this context. It's
simpler (shorter) than BOOST_COMPILE_TIME_ASSERT, and though I
usually don't recommend a name based on it's brevity, in this case I
like the fact that it's shorter. I don't like the BOOST prefix, but
understand the necessity for this little evil.

As for the other suggestions:

BOOST_COMPILER_ASSERT - I don't think conveys the fact that this is a
compile time assert.

BOOST_STATIC_PRECONDITION - Still has the same problems as
precondition, IMHO.

BOOST_STATIC_CHECK - Is OK, but doesn't convey to me what the action
will be. The assert version does, since it shares a name with the
assert macro.

William E. Kempf

Boost list run by bdawes at, gregod at, cpdaniel at, john at