Re: Using mixin in array declarations

2016-11-19 Thread Marduk via Digitalmars-d-learn
On Saturday, 19 November 2016 at 13:57:26 UTC, Jonathan M Davis wrote: On Saturday, November 19, 2016 09:46:08 Marduk via Digitalmars-d-learn wrote: [...] A string mixin literally puts the code there. So, doing mixin("int n = 10"); double[n][n] m; is identical to int n = 10; double[n][n] m;

Re: Using mixin in array declarations

2016-11-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 19, 2016 09:46:08 Marduk via Digitalmars-d-learn wrote: > In C one can do the following: > > # define N 10 > > double M[N][N]; > > > In D I would like to achieve the same result. I tried with: > > mixin("int N = 10;"); > > double[N][N] M; > > > but the compiler (DMD) complain

Re: Using mixin in array declarations

2016-11-19 Thread Marduk via Digitalmars-d-learn
On Saturday, 19 November 2016 at 09:49:48 UTC, rikki cattermole wrote: On 19/11/2016 10:46 PM, Marduk wrote: In C one can do the following: # define N 10 double M[N][N]; In D I would like to achieve the same result. I tried with: mixin("int N = 10;"); double[N][N] M; but the compiler (DM

Re: Using mixin in array declarations

2016-11-19 Thread rikki cattermole via Digitalmars-d-learn
On 19/11/2016 10:46 PM, Marduk wrote: In C one can do the following: # define N 10 double M[N][N]; In D I would like to achieve the same result. I tried with: mixin("int N = 10;"); double[N][N] M; but the compiler (DMD) complained with Error: variable N cannot be read at compile time. Wh

Using mixin in array declarations

2016-11-19 Thread Marduk via Digitalmars-d-learn
In C one can do the following: # define N 10 double M[N][N]; In D I would like to achieve the same result. I tried with: mixin("int N = 10;"); double[N][N] M; but the compiler (DMD) complained with Error: variable N cannot be read at compile time. What am I doing wrong?