<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2016-04-10 23:54 GMT+02:00 Sven Barth <span dir="ltr"><<a href="mailto:pascaldragon@googlemail.com" target="_blank">pascaldragon@googlemail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span><p>There are two things to differentiate:<br></p></span><p>
- Default() used in global variables<br>
- Default() used locally</p>
<p>The latter creates a local variable and basically FillChar()s it while the former creates a zero initialized global variable.<br>
(Thinking about this I could use the global variable approach also for local uses of Default(), with the only special case being generics, but that's another topic...)</p>
<p>So in the local case you'd need to add an Initialize() after the FillChar() call (if I haven't done that already).<br>
In the global case you'd need to add the corresponding calls to the implicit initialization function which is called before the unit's initialization section. Currently class constructors are called before that, but that's not good (though the implications are worse with the finalization) and is subject to change. Please don't work around it although right now it would work incorrectly for such variables used in class constructors.</p>
<p></p></blockquote><div>Thanks for introduction. Workaround is not a case, eventually patch to fix order of class constructor/destructor and variable implicit initialization/finalization (as mentioned in <a href="http://bugs.freepascal.org/view.php?id=29245" target="_blank">http://bugs.freepascal.org/view.php?id=29245</a> ). Anyway I do research in this direction to cover all possible usage of new operators (seems like Default intrinsic is the last one). </div><div><br></div><div>Sven, could you look at topic "Management operators AddRef and Copy vs Copy" thread? New operators are ready for test in branch, anyway we can adjust the naming of AddRef and Copy. Florian proposed "Clone" (instead of Copy) and "Copy" (instead of AddRef).</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><p>Note: and don't forget the finalization ;)</p></blockquote><div>"Finalize" is mentioned in thread name so it will not be forgotten ;)</div></div><div><br></div>-- <br><div><div dir="ltr"><div>Best regards,<br>Maciej Izak</div></div></div>
</div></div>