Better error messages - from reddit

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Mar 5 11:53:07 UTC 2019


On 3/4/19 1:18 PM, jmh530 wrote:
> On Monday, 4 March 2019 at 15:47:12 UTC, H. S. Teoh wrote:
>> [snip]
>>
>> This is why years ago I said both here and in the Phobos PR queue that 
>> sig constraints need to be written in such a way that anything that 
>> *might* possibly be intended for that function ought to be accepted, 
>> and static ifs should be used inside the function body to dispatch to 
>> the code that handles the corresponding template arguments, with an > 
>> assert(0) at the end that tells you why the arguments weren't matched. 
>> [snip]
> 
> What would be an example of a signature constraint that you think would 
> be worth keeping? I.e., why not do everything with static ifs?

Overloads with the same arity within the same module should use an 
umbrella constraint (disjunction of all supported cases) and static if 
inside. It would be nice if someone made a pass through Phobos doing 
that throughout.

Again: SAME arity, SAME module, use the umbrella constraint that is a 
DISJUNCTION of supported cases, distinguish INSIDE with static if.


More information about the Digitalmars-d mailing list