Help from the compiler when debugging failing template constraints - a pull request

Atila Neves via Digitalmars-d digitalmars-d at puremagic.com
Wed Oct 14 06:32:49 PDT 2015


On Wednesday, 14 October 2015 at 12:42:23 UTC, Artur Skawina 
wrote:
> On 10/14/15 10:26, Atila Neves via Digitalmars-d wrote:
>> On Monday, 28 September 2015 at 20:25:21 UTC, Atila Neves 
>> wrote:
>>> I've mentioned this many times before: template constraints 
>>> are like unittest blocks with asserts in D: great that 
>>> they're built-in easy to use. But when they fail, there's no 
>>> help in figuring out why.
>>>
>>> [...]
>> 
>> Huh, I thought this'd get more interest. I guess I have weird 
>> priorities! :P
>
> No, it's probably just that the people interested in this would 
> prefer a /proper/ solution, hence don't consider ad hoc hacks 
> to be cost effective, but actually counterproductive.
>
> artur

There can't be a "proper" solution without a language change, 
which is unlikely.
Personally, I'd prefer

     struct MyStruct: static isInputRange { ... }

to:

     @models!(MyStruct, isInputRange) struct MyStruct { ... }


But the latter is possible today and the former is unlikely to 
ever get approved. My original plan was to write a DIP for 
"static inheritance", I changed to this PR because I'm 90% sure 
the DIP would go nowhere and the PR makes things a lot better.

Atila


More information about the Digitalmars-d mailing list