of "Conditional Implementation" vs "Assertive Input Validation"

Chris NS ibisbasenji at gmail.com
Mon Jul 23 04:44:50 PDT 2012


It certainly makes sense.  Maybe the long term solution would be 
a way to embed those assertions in the conditions, but in the 
meantime the proposal would alleviate the error message issue.  I 
know I've often enough stared long and hard at a volume of 
template instantiation errors waiting for the real mistake to 
jump out at me.

----------

And for the curious, what I mean by embedding assertions in the 
conditions is quite literally what it sounds like:

Range minPos ( Range ) ( Range R1 )
if( is( inputRange!Range ) )
assert( !isInfinite!Range, "minPos cannot operate on infinite 
ranges." )
{
     ...
}

In which case the compiler would merge the condition expressions 
of the assertions into the if-condition, and remember the message 
strings associated with them.


More information about the Digitalmars-d mailing list