calling the default ctor static this() removes any such illusion.<div>----<br><div>struct A{</div><div>int[]x;</div><div>static this(){</div><div>x=[1,2,3];</div><div>}</div><div>}</div><div>void main(){</div><div>enum a=A.init;</div>
<div>static assert(a is A.init);</div><div>}</div><div>----<br></div><div>would work under this proposal.</div><div>What would be your alternate proposal that would still allow to initialize x to [1,2,3] in the ctor?</div>
<div><br><div><br><br><div class="gmail_quote">On Fri, May 17, 2013 at 4:46 PM, Igor Stepanov <span dir="ltr"><<a href="mailto:wazar.leollone@yahoo.com" target="_blank">wazar.leollone@yahoo.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">When programmer see constructor, he think that it will be evaluated each time when he create a new object.<br>
This code will seem obvious for any C++ coder.<br>
And this coder will be deceived.<br>
<br>
If we'll add default constructor to structs, we'll must safe of illusion, that constructor is called any time when new object have been created. And reject all cases when we can't provide this illusion.<br>
</blockquote></div><br></div></div></div>