Re: Find variable at run time

2013-05-18 Thread Josh
On Saturday, 18 May 2013 at 08:26:09 UTC, Dicebot wrote: On Saturday, 18 May 2013 at 02:09:49 UTC, Josh wrote: Bearophile, is your findVar an AA? It looks like it is, I just didn't think you could put refs in an AA. Thanks Josh It is AA and it stores pointers, not references. P.S. There ca

Re: Find variable at run time

2013-05-18 Thread Dicebot
On Saturday, 18 May 2013 at 02:09:49 UTC, Josh wrote: Bearophile, is your findVar an AA? It looks like it is, I just didn't think you could put refs in an AA. Thanks Josh It is AA and it stores pointers, not references. P.S. There can be found a lot of solutions but they will all do some k

Re: Find variable at run time

2013-05-17 Thread Josh
On Friday, 17 May 2013 at 22:15:09 UTC, bearophile wrote: Josh: Is something like this possible in D? void main() { int x, y, z; write("Increment which variable: "); string input = readln()[0..$ - 1]; findVar(input)++; writeln(x, y, z); } The Go language and its standard libra

Re: Find variable at run time

2013-05-17 Thread bearophile
Josh: Is something like this possible in D? void main() { int x, y, z; write("Increment which variable: "); string input = readln()[0..$ - 1]; findVar(input)++; writeln(x, y, z); } The Go language and its standard library make the usage of such runtime reflection much sim

Re: Find variable at run time

2013-05-17 Thread Adam D. Ruppe
Not with local variables, but you can with a struct. === import std.stdio; void main() { struct Vars { int x; int y; int z; ref int get(string name) { // allMembers gets the names of each member as a