<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">2013/5/16 Михаил Страшун <span dir="ltr"><<a href="mailto:m.strashun@gmail.com" target="_blank">m.strashun@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Wall of text incoming.<br>
<br>
First. I'd like to remind to several important properties of D structs:<br>
<br>
* They have both compile-time initialization and run-time one. First<br>
is T.init, second is T(...). Needing both is a perfectly valid need<br>
from the programmer, especially with generic code in question.<br></blockquote><div><br></div><div>T.init is statically known constant default value of a type and T(..) expression when applied to<br></div><div>the struct can be a struct literal, constructor invocation or an opCall.<br>
<br></div><div>Default value (T.init) is same both in compile time and runtime unless you deliberatly hack<br></div><div>generated object file at runtime. But this has nothing to do with <br>"compile-time initialization" and "runtime initialization".<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
* structs always have constructors. So this snippet is wrong:<br>
<div>> struct S<br>
> {<br>
> immutable int c = 123; // This should be static, compiler issues error<br>
> // No constructor<br>
> }<br>
</div>In fact, S has constructor. All structs have constructor with<br>
parameter count that matches member field count. And judging only by S<br>
definition you can't ever possibly say if "c" will be the same in all<br>
S instances or not.<br></blockquote><div><br></div><div>No. This S does not have a constructor. Expressions with "parameter count that mathces<br></div><div>member field count" is struct literal and it has nothing to do with implicit constructor generation<br>
</div><div>or calling any function. Please check things before you type.<br></div></div></div></div>