<div dir="auto"><div><br><div class="gmail_extra"><div class="gmail_quote">Am 28.11.2017 20:04 schrieb "Роман via fpc-pascal" <<a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>>:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">'Initialization' sections are executed in poorly predictable order, so I want to partially order them according to some form of explicit prioritization and execute before control flow enters main block (so I won't need to run all that initialization by hand, neither I would be able to forget to do that). </blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">If unit A uses unit B in the interface section then unit B's initialization section is always run before A's. For the implementation section the same holds true if there isn't a cycle otherwise it depends on the unit load order. </div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Like:<br>
<br>
unit UnitA;<br>
...<br>
procedure Init;<br>
<br>
initialization<br>
RegisterUnit('UnitA', @Init);<br>
end;<br>
<br>
unit UnitB;<br>
...<br>
procedure Init;<br>
<br>
initialization<br>
RegisterUnit('UnitB', @Init, {priority} +1);<br>
end;<br>
<br>
...<br>
procedure SortAndInitialize;<br>
...<br>
<br>
Can I run SortAndInitialize before 'main' without additional user actions?<br></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">No, you can't.</div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"></blockquote></div></div></div></div>