<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"><head><!--[if gte mso 9]><xml><o:OfficeDocumentSettings><o:AllowPNG/><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml><![endif]--></head><body><div style="color:#000; background-color:#fff; font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:13px"><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr">Srinivas,<br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr">The way the problem was mitigated is by checking references from other modules before unloading, and simply keeping the module in memory, as long as there are references to the unloaded module in the remaining part of the system.</div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr">It is described in section 5 of this document (forget the rest, just skip to section 5):</div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><a href="https://github.com/andreaspirklbauer/Oberon-experimental/blob/master/Documentation/DIFFERENCES-between-Experimental-Oberon-and-Original-Oberon.pdf" id="yui_3_16_0_ym19_1_1478930367016_16228">https://github.com/andreaspirklbauer/Oberon-experimental/blob/master/Documentation/DIFFERENCES-between-Experimental-Oberon-and-Original-Oberon.pdf</a><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr">Or, if you want, you can just check out the source code that implements all this here:</div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><a href="https://github.com/andreaspirklbauer/Oberon-experimental/blob/master/Sources/Kernel.Mod" id="yui_3_16_0_ym19_1_1478930367016_16321">https://github.com/andreaspirklbauer/Oberon-experimental/blob/master/Sources/Kernel.Mod</a>  (adds procedure CheckRef)<br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><a href="https://github.com/andreaspirklbauer/Oberon-experimental/blob/master/Sources/Modules.Mod" id="yui_3_16_0_ym19_1_1478930367016_16452">https://github.com/andreaspirklbauer/Oberon-experimental/blob/master/Sources/Modules.Mod</a>  (adds procedure CheckRef)<br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><a href="https://github.com/andreaspirklbauer/Oberon-experimental/blob/master/Sources/ORG.Mod" id="yui_3_16_0_ym19_1_1478930367016_16628">https://github.com/andreaspirklbauer/Oberon-experimental/blob/master/Sources/ORG.Mod</a>  (adds procedure variable offsets to descriptors)<br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr">Note that, as outlined in the PDF document cited above, in order for this to work, the type descriptor (and therefore also the Oberon object file format) and the descriptor for global data (e.g. global procedure variables) had to be extended with a list of *procedure variable offsets* - an idea that was originally implemented in MacOberon around 1990 and which I (essentially) adopted but also extended with a mechanism to *automatically* collect no longer referenced modules. But the changes needed to implement all that were absolutely minimal: just a few minor adaptations and only 2 (!) additional lines in the compiler (see procedures ORG.FindFlds, ORG.BuildTD, ORG.Nofrefs, ORG.FindRefs and ORG.Close) and only 3 (!) additional lines to module loader (see procedure Modules.Load). That's it!</div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr">In total, the implementation cost for all of the above was about 50-70 lines (depending on how one counts).</div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr">It completely does away with the need for finalization - which I always viewed with great suspicion (too complex, too many issues, seems like tinkering with the symptoms rather than with the root cause).</div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025" dir="ltr">Andreas</div><div id="yui_3_16_0_ym19_1_1478930367016_16025"><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16025">------------------------------------------------------------------------</div><div id="yui_3_16_0_ym19_1_1478930367016_16104">> Srinivas Nayak sinu.nayak2001 at gmail.com </div><div id="yui_3_16_0_ym19_1_1478930367016_16105">> Sat Nov 12 08:39:10 CET 2016</div><div id="yui_3_16_0_ym19_1_1478930367016_16116"><br id="yui_3_16_0_ym19_1_1478930367016_16117"></div><div id="yui_3_16_0_ym19_1_1478930367016_16118">> Yes, Andreas wrote...</div><div id="yui_3_16_0_ym19_1_1478930367016_16119"><br id="yui_3_16_0_ym19_1_1478930367016_16120"></div><div id="yui_3_16_0_ym19_1_1478930367016_16121">> "The case of inheritance (type extension in Oberon) is now fully covered in the latest version of safe module unloading in Experimental Oberon. ..."</div><div id="yui_3_16_0_ym19_1_1478930367016_16122"><br id="yui_3_16_0_ym19_1_1478930367016_16123"></div><div id="yui_3_16_0_ym19_1_1478930367016_16124">> Can anybody please summarize how he mitigated the problem?</div><div id="yui_3_16_0_ym19_1_1478930367016_16125">> I was thinking, Finalization can help us here.</div><div id="yui_3_16_0_ym19_1_1478930367016_16126">> But, interested to know the approach taken by Andreas to barring such deviousness.</div><div id="yui_3_16_0_ym19_1_1478930367016_16127"><br></div><div id="yui_3_16_0_ym19_1_1478930367016_16133">> With thanks and best regards,</div><div id="yui_3_16_0_ym19_1_1478930367016_16134"><br id="yui_3_16_0_ym19_1_1478930367016_16135"></div><div id="yui_3_16_0_ym19_1_1478930367016_16136">> Yours sincerely,</div><div dir="ltr" id="yui_3_16_0_ym19_1_1478930367016_16137">> Srinivas Nayak</div><div dir="ltr" id="yui_3_16_0_ym19_1_1478930367016_16137"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1478930367016_16137"><br></div></div></body></html>