Walter, I need a __trait please.

Stefan Koch via Digitalmars-d digitalmars-d at puremagic.com
Tue Mar 15 00:16:52 PDT 2016


On Tuesday, 15 March 2016 at 03:10:46 UTC, Nicholas Wilson wrote:
> On Tuesday, 15 March 2016 at 00:29:17 UTC, Stefan Koch wrote:
>> Hi,
>>
>> I found myself in need of __trait that might be useful to 
>> include.
>>
>> something that would give me the parameters of a the body of 
>> the lambda as string and the parmeters of a lambda as 
>> AliasSequence.
>> e.g
>> foreach (p;__traits(lambda, (x,y) => x < y)) {
>>  writeln(p);
>> }
>>
>> would output
>> x
>> y
>> x < y
>>
>> I am sure this is doable unfortunately I lack the insight into 
>> DMD to implement this in a reasonable amount of time, and code 
>> quality.
>>
>> Thanks in advance!
>>
>> Stefan
>
> Also can we have an isEnum and isStruct. yes 
> __traits(compiles,Fields!(__traits(getMember,moduleName, 
> member))) and the equivalent for enumMembers works but is very 
> ugly.

We have is (T == enum) and is(T == struct)


More information about the Digitalmars-d mailing list