is(x = module) vs. __traits(isModule, x)

Stefan Koch uplink.coder at googlemail.com
Wed Oct 7 21:01:28 UTC 2020


On Wednesday, 7 October 2020 at 20:58:21 UTC, Paul Backus wrote:

> Clever. Now try this:
>
>     writeln(Wrapper!("hello" + 1).compiles);
>
> Or this:
>
>     struct S { int x; }
>     int n = 123;
>     writeln(Wrapper!(S(n)).getMember!"x");
>
> Or this:
>
>     struct S { in x, y; }
>     writeln(Wrapper!S.allMembers);
>
> The problem with using templates to wrap __traits is that 
> __traits can do things that templates aren't allowed to do, 
> like take expressions as arguments, or evaluate to expressions 
> rather than symbols or constants.

Hmm seeing this written out I have to say ...
It does look neat ....

If you submit a DIP I can implement it for you.
It only looks neat without the underscores though :)


More information about the Digitalmars-d mailing list