Ideas how to improve template constraint errors???

Jason House jason.james.house at gmail.com
Thu Dec 5 17:22:24 PST 2013


On Thursday, 5 December 2013 at 13:55:30 UTC, Martin Nowak wrote:
> Ah well, this was a question for ideas.
> I don't really know to get there.

I can think of a few things:
1. The compiler could mark what made it reject a candidate. If it 
failed due to a template constraint it could flag the last 
evaluated condition. If the constraint passed, it could flag the 
arguments whose types did not match. Flagging could be with a 
special symbol. An IDE could use a different font, colors, bold 
etc.
2. If a constraint is a function requirement rather than a 
condition for matching, it could be replaced with a static assert.
3. It may be possible to embed constraints into a type 
specification. It might not help a lot, but may make it easier 
for people to parse the description easier.
4. I frequently think a lot of this constraint stuff could be 
done in some kind if cascading if then else style. I'm not sure 
how a failure would be reported, but it could greatly reduce the 
number of constraints.


More information about the Digitalmars-d mailing list