Re: __traits getMember is context sensetive?

2015-06-14 Thread JDemler via Digitalmars-d-learn
On Sunday, 14 June 2015 at 10:29:09 UTC, anonymous wrote: On Sunday, 14 June 2015 at 10:10:51 UTC, ketmar wrote: i.e. when it need a value in compile time. the interpreter is invoked, it evaluates (interprets) the given code (function or template instantiation), and then it returns result (or r

Re: __traits getMember is context sensetive?

2015-06-14 Thread JDemler via Digitalmars-d-learn
On Sunday, 14 June 2015 at 10:04:35 UTC, John Colvin wrote: On Sunday, 14 June 2015 at 09:46:56 UTC, JDemler wrote: On Sunday, 14 June 2015 at 05:52:00 UTC, ketmar wrote: oh, seems that i managed to make everything even less understandable... Your code works perfectly and makes at least some

Re: __traits getMember is context sensetive?

2015-06-14 Thread JDemler via Digitalmars-d-learn
On Sunday, 14 June 2015 at 05:52:00 UTC, ketmar wrote: oh, seems that i managed to make everything even less understandable... Your code works perfectly and makes at least some sense to me. Thank you. If i understand it correctly: __traits-time = templateinstatiation-time = pragma-time befo

Re: __traits getMember is context sensetive?

2015-06-13 Thread JDemler via Digitalmars-d-learn
On Saturday, 13 June 2015 at 23:51:32 UTC, JDemler wrote: I have another one :) module test; struct S{ string member1; int member2; } string test(string[] a) { const S s = { member1:"It is also important to go to Mars!"}; const string y = a[0]; return y; } void main() { enum e = [

Re: __traits getMember is context sensetive?

2015-06-13 Thread JDemler via Digitalmars-d-learn
I have another one :) module test; struct S{ string member1; int member2; } string test(string[] a) { const S s = { member1:"It is also important to go to Mars!"}; const string y = a[0]; return y; } void main() { enum e = ["member1","member2"]; pragma(msg, e[0]); pragma(msg, te

Re: __traits getMember is context sensetive?

2015-06-13 Thread JDemler via Digitalmars-d-learn
On Saturday, 13 June 2015 at 10:26:06 UTC, Marc Schütz wrote: On Saturday, 13 June 2015 at 10:01:45 UTC, JDemler wrote: Hey, i am trying to wrap my head around __traits. One thing i just do not understand is following: struct S{ string member1; int member2; } void main(string[] args) {

__traits getMember is context sensetive?

2015-06-13 Thread JDemler via Digitalmars-d-learn
Hey, i am trying to wrap my head around __traits. One thing i just do not understand is following: struct S{ string member1; int member2; } void main(string[] args) { foreach(typeStr; __traits(allMembers, S)) { auto tp = __traits(getMember, S, typeStr); static if (__trait