Interfaces, traits, concepts, and my idea for a DIP

Atila Neves via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 29 07:51:51 PDT 2015


On Wednesday, 29 July 2015 at 08:25:04 UTC, Roland Hadinger wrote:
> On Tuesday, 28 July 2015 at 12:49:17 UTC, Atila Neves wrote:
>> So... instead of having traits / concepts, what I wanted from 
>> D is to be able to do this:
>>
>> struct MyRange: isInputRange { ... }
>
> +1
>
>> or
>>
>> struct MyRange: static isInputRange { ... } // that way 
>> classes could do this too
>
> What about this instead:
>
>     @satisfies(isInputRange) struct MyRange { ... }
>
> which is not as terse, but maybe less confusing, because 
> intuitively ':' could be mistaken to mean 'extends'.
>
> 'static' has too many meanings already for my taste. I really 
> don't like it when frequently used keywords are reused to mean 
> different things in slightly different places.

That looks nice, but who's going to check it? UDAs have to be 
reflected on to well, do anything. At least a template mixin will 
cause a static assert to fail.

Atila


More information about the Digitalmars-d mailing list