On 01/17/2014 02:42 AM, Andrei Alexandrescu wrote:
class Widget
{
private int x;
private Widget parent;
this(int y) { x = y; }
...
// Here's the interesting part
static Widget init = new Widget(42);
}
Currently the last line doesn't compile, but we can make it work if the
respective constructor is callable during compilation. The compiler will
allocate a static buffer for the "new"ed Widget object and will make
init point there.
immutable(Widget) iwidget; // ?
