Daniel Murphy:

What do you think about https://github.com/D-Programming-Language/dmd/pull/3799 ?

Basically, turn obviously invalid failing function calls into compile-time errors. IMO this pushes in-contracts well out of the useless area.

I like compile-time tests, you can see it from several of my last posts, but: 1) It's better to be able to express general tests using CTFE, instead of covering a limited but growing list of cases. The general solution needs only half page of text to be explained in a next version of the TDPL, while your proposal will need a growing list of cases; 2) For reasons Walter has explained elsewhere, those tests need to be explicit, even syntactically-wise (and Walter has a strong opinion on this, so it's unlikely you will change his mind. And I agree with him on this).

So far I've seen only one proposal to do this (the Enum Preconditions), and it too has some limits (caused by compilation units, that can be removed turning the Enum Preconditions into things handled like templates).

Bye,
bearophile

Reply via email to