std.unittests for (final?) review

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Jan 6 07:10:46 PST 2011


On 1/5/11 9:35 PM, Michel Fortin wrote:
> I'm not sold on the concept. The whole point of this module seems to
> offer a way to replace the built-in assertion mechanism with a
> customized one, with the sole purpose of giving better error messages.
> So we're basically encouraging the use of:
>
> assertPredicate!"a > b"(a, b, "message");
>
> instead of:
>
> assert(a > b, "message");
>
> It looks like an uglification of the language to me.
>
> I agree that getting better error messages is important (very important
> in fact), but keeping the code clean is important too. If the built-in
> assert doesn't give us good enough error messages, perhaps it's the
> built-in assert that should be improved. The compiler could give the
> values on both side of the operator to the assertion handler, which
> would in turn print values and operator as part of the error message.
>
> So to me this module is a temporary fix until the compiler is capable of
> giving the necessary information to the assertion handler. I sure hope
> it won't be needed for too long.
>
> (Note: this criticism doesn't apply to those assertions dealing with
> exceptions.)

I think this is a valid improvement that can be brought to the language, 
but we're at a point in D's history where we should ask ourselves how we 
can get stuff done in the existing language instead of how we can change 
the language to make stuff easier to get done.

Andrei


More information about the Digitalmars-d mailing list