the traits trap

Sergei Nosov via Digitalmars-d digitalmars-d at puremagic.com
Thu Nov 20 23:25:58 PST 2014


On Friday, 21 November 2014 at 04:08:52 UTC, Steven Schveighoffer 
wrote:
> Can anyone figure out a good solution to this problem? I like 
> template constraints, but they are just too black-boxy. Would 
> we have to signify that some enum is actually a trait and so 
> the compiler would know to spit out the junk of compiling? 
> Would it make sense to add some __traits function that allows 
> one to signify that this is a special trait thing?
>
> This is one area that D's templates are very user-unfriendly.
>
> -Steve

I would second this. Personally, I have the same "not very 
pleasant" experience debugging template constraints.

Since more often than not the constraints have the form of:

if (clause1 && clause2 && clause3 ...)

my naive proposal would be to show which clause was first to be 
false in the error message.

However, I have no idea if this could be implemented easily.


More information about the Digitalmars-d mailing list