std.unittests for (final?) review

Michel Fortin michel.fortin at michelf.com
Thu Jan 6 07:36:55 PST 2011


On 2011-01-06 10:10:46 -0500, Andrei Alexandrescu 
<SeeWebsiteForEmail at erdani.org> said:

> 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.

It's not a language change. The language doesn't mandate any particular 
error message for assertions. It's a quality of implementation issue.


-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list