Re: Run-time initialised static variables

2018-02-09 Thread dekevin via Digitalmars-d-learn
On Tuesday, 6 February 2018 at 23:03:07 UTC, dekevin wrote: Hello everyone, I just ran into the problem, that I need a static variable, where the initialisation code for that variable is only accessible during run-time (since part of the initialisation code will be dynamically linked). Is th

Re: Run-time initialised static variables

2018-02-07 Thread dekevin via Digitalmars-d-learn
On Wednesday, 7 February 2018 at 20:10:10 UTC, dekevin wrote: On Wednesday, 7 February 2018 at 16:26:16 UTC, Dominikus Dittes Scherkl wrote: On Wednesday, 7 February 2018 at 12:10:38 UTC, dekevin wrote: struct ℚ{ ℤ num, den; //cannot call constructors on these, since they require gmp_in

Re: Run-time initialised static variables

2018-02-07 Thread dekevin via Digitalmars-d-learn
On Wednesday, 7 February 2018 at 16:26:16 UTC, Dominikus Dittes Scherkl wrote: On Wednesday, 7 February 2018 at 12:10:38 UTC, dekevin wrote: struct ℚ{ ℤ num, den; //cannot call constructors on these, since they require gmp_init, which requires runtime code //Default initialiser dis

Re: Run-time initialised static variables

2018-02-07 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
On Wednesday, 7 February 2018 at 12:10:38 UTC, dekevin wrote: struct ℚ{ ℤ num, den; //cannot call constructors on these, since they require gmp_init, which requires runtime code //Default initialiser disabled, since else num=0,den=0 You can use a different default initializer:

Re: Run-time initialised static variables

2018-02-07 Thread dekevin via Digitalmars-d-learn
On Wednesday, 7 February 2018 at 00:31:01 UTC, Jonathan M Davis wrote: On Tuesday, February 06, 2018 23:50:52 dekevin via Digitalmars-d-learn wrote: Thanks a lot! I will change all my initialisations to static constructors now. I should point out that the downside to static constructors is th

Re: Run-time initialised static variables

2018-02-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, February 06, 2018 23:50:52 dekevin via Digitalmars-d-learn wrote: > Thanks a lot! I will change all my initialisations to static > constructors now. I should point out that the downside to static constructors is that if you have modules that recursively depend on each other, the progr

Re: Run-time initialised static variables

2018-02-06 Thread dekevin via Digitalmars-d-learn
On Tuesday, 6 February 2018 at 23:50:52 UTC, dekevin wrote: On Tuesday, 6 February 2018 at 23:21:36 UTC, Jonathan M Davis wrote: [...] Thanks a lot! I will change all my initialisations to static constructors now. The only additional problem I have, is that ℚInf has a disabled default constr

Re: Run-time initialised static variables

2018-02-06 Thread dekevin via Digitalmars-d-learn
On Tuesday, 6 February 2018 at 23:21:36 UTC, Jonathan M Davis wrote: On Tuesday, February 06, 2018 23:03:07 dekevin via Digitalmars-d-learn wrote: Hello everyone, I just ran into the problem, that I need a static variable, where the initialisation code for that variable is only accessible duri

Re: Run-time initialised static variables

2018-02-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, February 06, 2018 23:03:07 dekevin via Digitalmars-d-learn wrote: > Hello everyone, > I just ran into the problem, that I need a static variable, where > the initialisation code for that variable is only accessible > during run-time (since part of the initialisation code will be > dyna

Run-time initialised static variables

2018-02-06 Thread dekevin via Digitalmars-d-learn
Hello everyone, I just ran into the problem, that I need a static variable, where the initialisation code for that variable is only accessible during run-time (since part of the initialisation code will be dynamically linked). Is there a way to do this in D? To be a bit more concrete, this i