++Phobos

FeepingCreature feepingcreature at gmail.com
Thu Oct 17 10:31:39 UTC 2019


On Thursday, 17 October 2019 at 03:46:23 UTC, rikki cattermole 
wrote:
> On 17/10/2019 4:32 PM, Jesse Phillips wrote:
>> Now as you said, it doesn't improve the error message. But 
>> what if the language changed so it could?
>
> That would require flow analysis and it won't give good names 
> to different aspects.
>
> We have done research into template constraints and to improve 
> the error messages there. But aggregate checks like 
> isInputRange and with that implements, the compiler can't 
> understand it even with flow analysis sadly.
>
I still think the only change that is needed is to make the 
operators return an error value instead of a boolean on failure. 
The error value then just needs to propagate properly through && 
and ||, and you should get an unambiguous error. You could even 
add further information with a wrapper template, as long as the 
error object is inspectable and rewritable.

I don't think the right approach is to have the compiler 
automagically produce good error messages, but rather give the 
template developers tools to help the compiler inform the user 
what actually went wrong.


More information about the Digitalmars-d mailing list