Re: Generating code based on UDA

2014-10-26 Thread Rares Pop via Digitalmars-d-learn
I have found the problem. It was the nested mixin that was causing the scope degradation (not sure if that is intended behaviour). The correct way to iterate through members and get their attribute is like this: foreach(member; __traits(allMembers,T)) {

Re: Generating code based on UDA

2014-10-25 Thread Rares Pop via Digitalmars-d-learn
I think it is a bug. Executing linked code from a mixin statement should not reduce the scope of the mixin, IMHO. I will file a bug report. On Saturday, 25 October 2014 at 21:35:44 UTC, Ali Çehreli wrote: On 10/25/2014 08:56 AM, Rares Pop wrote: > Indeed it worked. What is the rationale behi

Re: Generating code based on UDA

2014-10-25 Thread Ali Çehreli via Digitalmars-d-learn
On 10/25/2014 08:56 AM, Rares Pop wrote: > Indeed it worked. What is the rationale behind the mixin(fullName) ? __traits(getAttributes) requires a symbol but fullName is a string. Mixing it in as code fulfills the requirement. > However, in my project the injections function, the @Inject UDA

Re: Generating code based on UDA

2014-10-25 Thread Rares Pop via Digitalmars-d-learn
On Saturday, 25 October 2014 at 16:01:29 UTC, Rares Pop wrote: I've uploaded the code here: https://github.com/fusionbeam/infuse compiling with ldc2 exhibits the same behaviour. 'Error: undefined identifier B'

Re: Generating code based on UDA

2014-10-25 Thread Rares Pop via Digitalmars-d-learn
I've uploaded the code here: https://github.com/fusionbeam/infuse

Re: Generating code based on UDA

2014-10-25 Thread Rares Pop via Digitalmars-d-learn
Ali, Many thanks for your help. Indeed it worked. What is the rationale behind the mixin(fullName) ? However, in my project the injections function, the @Inject UDA struct and some other dependencies are defined in a library (libinfuse). In this format the compiler gives the undefined ident

Re: Generating code based on UDA

2014-10-25 Thread Rares Pop via Digitalmars-d-learn
Ali, Many thanks for your help. What is the rationale for mixin(fullName) ?

Re: Generating code based on UDA

2014-10-25 Thread Ali Çehreli via Digitalmars-d-learn
On 10/25/2014 07:45 AM, Rares Pop wrote: On Saturday, 25 October 2014 at 13:53:35 UTC, Adam D. Ruppe wrote: On Saturday, 25 October 2014 at 13:45:29 UTC, Rares Pop wrote: What do you mean by copy/pasting ? I literally copied the code in your post (and fixed a missing semicolon) and got it to

Re: Generating code based on UDA

2014-10-25 Thread Rares Pop via Digitalmars-d-learn
On Saturday, 25 October 2014 at 13:53:35 UTC, Adam D. Ruppe wrote: On Saturday, 25 October 2014 at 13:45:29 UTC, Rares Pop wrote: What do you mean by copy/pasting ? I literally copied the code in your post (and fixed a missing semicolon) and got it to compile. Passing A as an argument to in

Re: Generating code based on UDA

2014-10-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 25 October 2014 at 13:45:29 UTC, Rares Pop wrote: What do you mean by copy/pasting ? I literally copied the code in your post (and fixed a missing semicolon) and got it to compile. Passing A as an argument to injections should work. You can also use this and typeof(this) inside

Re: Generating code based on UDA

2014-10-25 Thread Rares Pop via Digitalmars-d-learn
Thanks for the quick response. What do you mean by copy/pasting ? On Saturday, 25 October 2014 at 13:40:56 UTC, Adam D. Ruppe wrote: On Saturday, 25 October 2014 at 13:37:56 UTC, Rares Pop wrote: Aiming to generate code based on UDA I wonder if the following is possible: Yes, and copy/pasting

Re: Generating code based on UDA

2014-10-25 Thread Shammah Chancellor via Digitalmars-d-learn
On 2014-10-25 13:37:54 +, Rares Pop said: Hello everyone, I am trying to understand UDA traits scoping while mixing in code. Aiming to generate code based on UDA I wonder if the following is possible: class A { @Inject Logger logger; @Inject SomeOtherClass dependency;

Re: Generating code based on UDA

2014-10-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 25 October 2014 at 13:37:56 UTC, Rares Pop wrote: Aiming to generate code based on UDA I wonder if the following is possible: Yes, and copy/pasting that works for me...

Generating code based on UDA

2014-10-25 Thread Rares Pop via Digitalmars-d-learn
Hello everyone, I am trying to understand UDA traits scoping while mixing in code. Aiming to generate code based on UDA I wonder if the following is possible: class A { @Inject Logger logger; @Inject SomeOtherClass dependency; mixin injections!(A) ... } In "injections" funct