<pclass="commentary firstcommentary"><aid="SP1"class="paragraph-anchor"></a><b>§1. </b>Inform 7 compiles source text to a single "main" Inter tree. That tree must
then be joined with other Inter trees for kits such as BasicInformKit, a
process called "linking", for want of a better word.<supid="fnref:1"><ahref="#fn:1"rel="footnote">1</a></sup>
</p>
<pclass="commentary">Only the <ahref="../supervisor-module/index.html"class="internal">supervisor</a> module knows which kits need to be linked in; the main
Inter tree doesn't contain this information.<supid="fnref:2"><ahref="#fn:2"rel="footnote">2</a></sup>
</p>
<ulclass="footnotetexts"><liclass="footnote"id="fn:1"><pclass="inwebfootnote"><supid="fnref:1"><ahref="#fn:1"rel="footnote">1</a></sup> Unlike the C linking process, it is not symmetrical. One Inter tree is
made by <ahref="../inter/index.html"class="internal">inter</a>, and the others by <ahref="../inter/index.html"class="internal">inter</a>, for one thing.
<ahref="#fnref:1"title="return to text">↩</a></p></li><liclass="footnote"id="fn:2"><pclass="inwebfootnote"><supid="fnref:2"><ahref="#fn:2"rel="footnote">2</a></sup> Just as a C-compiled binary may be made by linking <spanclass="extract"><spanclass="extract-syntax">alpha.o</span></span>, <spanclass="extract"><spanclass="extract-syntax">beta.o</span></span> and
<spanclass="extract"><spanclass="extract-syntax">gamma.o</span></span> together, but the fact that these are the three <spanclass="extract"><spanclass="extract-syntax">*.o</span></span> files needed
to make the finished article is recorded only in the makefile for the program.
It's a matter for the build process and not for the compiler.
<ahref="#fnref:2"title="return to text">↩</a></p></li></ul>
<pclass="commentary firstcommentary"><aid="SP2"class="paragraph-anchor"></a><b>§2. </b>The list of Inter trees to link with is worked out by the <ahref="../supervisor-module/index.html"class="internal">supervisor</a>,
which calls the following function to obtain a way to record each "requirement":
<ulclass="endnotetexts"><li>The structure attachment_instruction is private to this section.</li></ul>
<pclass="commentary firstcommentary"><aid="SP3"class="paragraph-anchor"></a><b>§3. </b>Linking begins with the following stage. Note that the list of requirements
made by <ahref="../supervisor-module/index.html"class="internal">supervisor</a> is now stored in <spanclass="extract"><spanclass="extract-syntax">step->ephemera.requirements_list</span></span>.
<spanclass="plain-syntax"></span><spanclass="named-paragraph-container code-font"><ahref="4-lbks.html#SP3_1"class="named-paragraph-link"><spanclass="named-paragraph">Load the Inter for the kit into the sidecar</span><spanclass="named-paragraph-number">3.1</span></a></span><spanclass="plain-syntax">;</span>
<spanclass="plain-syntax"></span><spanclass="named-paragraph-container code-font"><ahref="4-lbks.html#SP3_2"class="named-paragraph-link"><spanclass="named-paragraph">Look for duplicate definitions</span><spanclass="named-paragraph-number">3.2</span></a></span><spanclass="plain-syntax">;</span>
<spanclass="plain-syntax"></span><spanclass="named-paragraph-container code-font"><ahref="4-lbks.html#SP3_3"class="named-paragraph-link"><spanclass="named-paragraph">Migrate the bulk of the code from the sidecar to the main tree</span><spanclass="named-paragraph-number">3.3</span></a></span><spanclass="plain-syntax">;</span>
<pclass="commentary firstcommentary"><aid="SP3_1"class="paragraph-anchor"></a><b>§3.1. </b>A kit will, if properly prepared, contain a binary Inter file for each possible
architecture which may be needed. For testing purposes, the following actually
allows a textual Inter file to be used instead, but this isn't intended for
regular users: it would be quite slow to read in.
</p>
<pclass="commentary"><spanclass="named-paragraph-container code-font"><spanclass="named-paragraph-defn">Load the Inter for the kit into the sidecar</span><spanclass="named-paragraph-number">3.1</span></span><spanclass="comment-syntax"> =</span>
<spanclass="plain-syntax"></span><spanclass="identifier-syntax">internal_error</span><spanclass="plain-syntax">(</span><spanclass="string-syntax">"no arch file for requirement"</span><spanclass="plain-syntax">);</span>
<spanclass="plain-syntax"></span><spanclass="named-paragraph-container code-font"><ahref="4-lbks.html#SP3_2_1"class="named-paragraph-link"><spanclass="named-paragraph">A clash of definitions seems to have occurred</span><spanclass="named-paragraph-number">3.2.1</span></a></span><spanclass="plain-syntax">;</span>
<spanclass="plain-syntax"> }</span>
<spanclass="plain-syntax"> }</span>
<spanclass="plain-syntax"> }</span>
<spanclass="plain-syntax"> }</span>
</pre>
<ulclass="endnotetexts"><li>This code is used in <ahref="4-lbks.html#SP3">§3</a>.</li></ul>
<pclass="commentary firstcommentary"><aid="SP3_2_1"class="paragraph-anchor"></a><b>§3.2.1. </b><spanclass="named-paragraph-container code-font"><spanclass="named-paragraph-defn">A clash of definitions seems to have occurred</span><spanclass="named-paragraph-number">3.2.1</span></span><spanclass="comment-syntax"> =</span>
<spanclass="plain-syntax"></span><spanclass="reserved-syntax">if</span><spanclass="plain-syntax"> (</span><spanclass="identifier-syntax">override</span><spanclass="plain-syntax">) </span><spanclass="named-paragraph-container code-font"><ahref="4-lbks.html#SP3_2_1_1"class="named-paragraph-link"><spanclass="named-paragraph">Override the new definition with the existing one</span><spanclass="named-paragraph-number">3.2.1.1</span></a></span>
<spanclass="plain-syntax"></span><spanclass="reserved-syntax">else</span><spanclass="plain-syntax"></span><spanclass="named-paragraph-container code-font"><ahref="4-lbks.html#SP3_2_1_2"class="named-paragraph-link"><spanclass="named-paragraph">Throw an error for the duplication</span><spanclass="named-paragraph-number">3.2.1.2</span></a></span><spanclass="plain-syntax">;</span>
</pre>
<ulclass="endnotetexts"><li>This code is used in <ahref="4-lbks.html#SP3_2">§3.2</a>.</li></ul>
<pclass="commentary firstcommentary"><aid="SP3_2_1_1"class="paragraph-anchor"></a><b>§3.2.1.1. </b>The following (unfortunately) has to do something subtle. We need the definition
of <spanclass="extract"><spanclass="extract-syntax">defn_name</span></span> to be the one in the main tree; that means <spanclass="extract"><spanclass="extract-syntax">sidecar_end</span></span> has to have
its present definition struck, i.e., removed entirely from the <spanclass="extract"><spanclass="extract-syntax">sidecar</span></span> tree.
This may remove something as simple as a single constant definition, or as large
as a huge package holding the body of a function. Then, <spanclass="extract"><spanclass="extract-syntax">sidecar_end</span></span> has to
be redefined as something in the main tree. But since transmigration has not yet
happened, we can't just wire it there. We have to wire it to a plug with name
<spanclass="extract"><spanclass="extract-syntax">defn_tree</span></span> instead; and then after transmigration this will be connected to a
socket in the main tree connecting to <spanclass="extract"><spanclass="extract-syntax">rival_end</span></span>.
</p>
<pclass="commentary">But even that isn't quite enough. We can't allow the <spanclass="extract"><spanclass="extract-syntax">connectors</span></span> package of
<spanclass="extract"><spanclass="extract-syntax">sidecar</span></span> to contain a socket name which is the same as a socket name in the
<spanclass="extract"><spanclass="extract-syntax">connectors</span></span> package of the main tree <spanclass="extract"><spanclass="extract-syntax">I</span></span>. It might seem that we can just delete
the now-unwanted socket wired to the old definition; but we cannot, because other
symbols in the same kit might already be wired to it. So we keep the old socket,
but rename it with a name which will avoid name collisions, striking it out of
the symbols table dictionary.
</p>
<pclass="commentary"><spanclass="named-paragraph-container code-font"><spanclass="named-paragraph-defn">Override the new definition with the existing one</span><spanclass="named-paragraph-number">3.2.1.1</span></span><spanclass="comment-syntax"> =</span>
<spanclass="plain-syntax"></span><spanclass="identifier-syntax">LOGIF</span><spanclass="plain-syntax">(</span><spanclass="identifier-syntax">INTER_CONNECTORS</span><spanclass="plain-syntax">, </span><spanclass="string-syntax">"After overriding the kit definition, we have:\n"</span><spanclass="plain-syntax">);</span>
<spanclass="plain-syntax"></span><spanclass="identifier-syntax">LOGIF</span><spanclass="plain-syntax">(</span><spanclass="identifier-syntax">INTER_CONNECTORS</span><spanclass="plain-syntax">, </span><spanclass="string-syntax">"Socket renamed as $3 ~~> $3\n"</span><spanclass="plain-syntax">, </span><spanclass="identifier-syntax">S</span><spanclass="plain-syntax">, </span><spanclass="identifier-syntax">Wiring::cable_end</span><spanclass="plain-syntax">(</span><spanclass="identifier-syntax">S</span><spanclass="plain-syntax">));</span>
<spanclass="plain-syntax"></span><spanclass="identifier-syntax">LOGIF</span><spanclass="plain-syntax">(</span><spanclass="identifier-syntax">INTER_CONNECTORS</span><spanclass="plain-syntax">, </span><spanclass="string-syntax">"A new plug $3\n"</span><spanclass="plain-syntax">, </span><spanclass="identifier-syntax">plug</span><spanclass="plain-syntax">);</span>
<spanclass="plain-syntax"></span><spanclass="identifier-syntax">LOGIF</span><spanclass="plain-syntax">(</span><spanclass="identifier-syntax">INTER_CONNECTORS</span><spanclass="plain-syntax">, </span><spanclass="string-syntax">"Kit defn symbol $3 ~~> $3\n"</span><spanclass="plain-syntax">,</span>
<ulclass="endnotetexts"><li>This code is used in <ahref="4-lbks.html#SP3_2_1">§3.2.1</a>.</li></ul>
<pclass="commentary firstcommentary"><aid="SP3_2_1_2"class="paragraph-anchor"></a><b>§3.2.1.2. </b><spanclass="named-paragraph-container code-font"><spanclass="named-paragraph-defn">Throw an error for the duplication</span><spanclass="named-paragraph-number">3.2.1.2</span></span><spanclass="comment-syntax"> =</span>
<spanclass="plain-syntax"></span><spanclass="string-syntax">"found a second definition of the name '%S' when loading '%S'"</span><spanclass="plain-syntax">,</span>
<ulclass="endnotetexts"><li>This code is used in <ahref="4-lbks.html#SP3_2_1">§3.2.1</a>.</li></ul>
<pclass="commentary firstcommentary"><aid="SP3_3"class="paragraph-anchor"></a><b>§3.3. </b>The "attachment point" for the kit will be something like <spanclass="extract"><spanclass="extract-syntax">/main/BasicInformKit</span></span>.
<pclass="commentary"><spanclass="named-paragraph-container code-font"><spanclass="named-paragraph-defn">Migrate the bulk of the code from the sidecar to the main tree</span><spanclass="named-paragraph-number">3.3</span></span><spanclass="comment-syntax"> =</span>
<spanclass="plain-syntax"></span><spanclass="identifier-syntax">WRITE_TO</span><spanclass="plain-syntax">(</span><spanclass="identifier-syntax">STDERR</span><spanclass="plain-syntax">, </span><spanclass="string-syntax">"sought attachment material at: %S\n"</span><spanclass="plain-syntax">, </span><spanclass="identifier-syntax">req</span><spanclass="plain-syntax">-></span><spanclass="element-syntax">attachment_point</span><spanclass="plain-syntax">);</span>
<spanclass="plain-syntax"></span><spanclass="identifier-syntax">internal_error</span><spanclass="plain-syntax">(</span><spanclass="string-syntax">"unable to find attachment point package"</span><spanclass="plain-syntax">);</span>