Err compile time interpreter my function!

Tobias Pankrath via Digitalmars-d digitalmars-d at puremagic.com
Fri Dec 26 00:55:36 PST 2014


---
class C
{
      int a = foo(); // foo is called at compile time
}
---

Reduced test case:

---
class S
{
     int a = compileTime(1);
     int b = compileTime(2);
}

int compileTime(int i) { import std.stdio; writeln("ct"); return
i; }
---

This works as expected. To initialize your fields at runtime
(using a constructor) will solve your problem.


More information about the Digitalmars-d mailing list