Request: traits isImplemented

JS js.mdnq at gmail.com
Fri Jul 5 07:59:19 PDT 2013


On Friday, 5 July 2013 at 10:55:26 UTC, Jacob Carlborg wrote:
> On 2013-07-05 11:52, JS wrote:
>> I have a request to add to __traits to check if a 
>> method/property of a
>> class/struct is actually implemented or not.
>>
>> interface A { void myfunc(); }
>>
>> class B : A { } // myfunc not implemented
>> class C : A { void myfunc() { ... } // myfunc implemented
>>
>> This may seem odd but I need it for conditional mixin 
>> compilation to add
>> in the methods when they are not implemented. A sort of 
>> default proxy,
>> wrapper, or composite pattern implementer. It reduces 
>> boilerplate code
>> significantly.
>>
>> Unfortunately allMembers returns methods that are not actually
>> implemented or part of the class.
>>
>> Something like allImmediateMembers would be useful where it 
>> only returns
>> the actually explicit members of the immediate class/struct 
>> that it is
>> used on and accomplish the same task.
>
> derivedMembers perhaps:
>
> http://dlang.org/traits.html#derivedMembers

This doesn't work with overloaded members. It's possible that a 
function with the same name may be completely unrelated to the 
interface being implemented.


More information about the Digitalmars-d mailing list