of "Conditional Implementation" vs "Assertive Input Validation"

Jacob Carlborg doob at me.com
Mon Jul 23 04:43:36 PDT 2012


On 2012-07-23 13:10, monarch_dodra wrote:
> I've been putting my nose in std.algorithm recently, specifically,
> requirements of algorithms.
>
> I must say I'm a big fan of conditional implementations. Given the
> genericity of templates (!), it can be very hard to overload them
> correct without conditional implementation. It is a really useful
> language feature
>
> That said, more often than not, they are also used to validate input.
> While this is a good thing, when a developer DOES try to call an
> algorithm with invalid input, he is greeted with the cryptic:
> "Error: template foo does not match any function template declaration"
> Followed by the (potentially long) list of candidates.
> More often than not, the conditional implementations are actually quite
> complicated, and contain up to 5 or 6 different conditions.

I think this is really a problem with std.algorithm.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list