Re: Avoiding __traits(getAttributes, ...) on alias

2014-05-10 Thread Vlad Levenfeld via Digitalmars-d-learn
Agreed, new bug report submitted.

Re: Avoiding __traits(getAttributes, ...) on alias

2014-05-10 Thread Philippe Sigaud via Digitalmars-d-learn
> else // doesn't compile, member is not accessible error > foreach (type; __traits (getAttributes, mixin(`T.`~member))) > static if (is (type == attribute)) > return true; > return false; > Maybe its trying to use it inside of __traits that is causing it? Maybe __traits is

Re: Avoiding __traits(getAttributes, ...) on alias

2014-05-10 Thread Vlad Levenfeld via Digitalmars-d-learn
I don't have any examples of the const bool thing not working, its just something I feel like I recall, though I could be mistaking it for the __traits example.

Re: Avoiding __traits(getAttributes, ...) on alias

2014-05-10 Thread Vlad Levenfeld via Digitalmars-d-learn
because this works: foreach (type; mixin(`__traits (getAttributes, T.`~member~`)`)) static if (is (type == attribute)) return true;

Re: Avoiding __traits(getAttributes, ...) on alias

2014-05-10 Thread Vlad Levenfeld via Digitalmars-d-learn
I'm not really sure. Here is an example of the problem: const bool has_attribute (T, string member, alias attribute) () { static if (1) // ok mixin( `foreach (type; __traits (getAttributes, T.`~member~`))` `static if (is (type == attribute))` `return true;` );

Re: Avoiding __traits(getAttributes, ...) on alias

2014-05-09 Thread Philippe Sigaud via Digitalmars-d-learn
Vlad Levenfeld: > but beware I've noticed that sometimes this is not > equivalent to the previous version and I'm not sure how or why that happens. > In particular I notice that > > mixin("const bool value = "~expr~";)"); > and > const bool value = mixin(expr); > > are not the same, for some re

Re: Avoiding __traits(getAttributes, ...) on alias

2014-05-09 Thread Vlad Levenfeld via Digitalmars-d-learn
I've recently found out that you can deal with the abundance of backticks and escapes in a couple of ways: q{ your code here... } will resolve to a string but your editor can still highlight it as D code, making it more readable. also, turning things like: mixin ("if ("~expr~")") into: if

Re: Avoiding __traits(getAttributes, ...) on alias

2014-05-09 Thread Stefan Frijters via Digitalmars-d-learn
On Friday, 9 May 2014 at 12:19:12 UTC, John Colvin wrote: On Friday, 9 May 2014 at 11:53:59 UTC, Stefan Frijters wrote: I've been playing with UDAs a bit and I wanted to find all variables with a particular attribute in various modules. I thought I had it cracked, until I added a module that co

Re: Avoiding __traits(getAttributes, ...) on alias

2014-05-09 Thread John Colvin via Digitalmars-d-learn
On Friday, 9 May 2014 at 11:53:59 UTC, Stefan Frijters wrote: I've been playing with UDAs a bit and I wanted to find all variables with a particular attribute in various modules. I thought I had it cracked, until I added a module that contains an alias declaration, which makes it choke when try

Avoiding __traits(getAttributes, ...) on alias

2014-05-09 Thread Stefan Frijters via Digitalmars-d-learn
I've been playing with UDAs a bit and I wanted to find all variables with a particular attribute in various modules. I thought I had it cracked, until I added a module that contains an alias declaration, which makes it choke when trying to execute __traits(getAttributes, ...). A small example i