<html><head></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_1479650735561_3060">Felix,</div><div id="yui_3_16_0_ym19_1_1479650735561_3060" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1479650735561_3060" dir="ltr">below is the output (under Experimental Oberon) of a modified set of your modules A, B, and C (source code appended below).</div><div id="yui_3_16_0_ym19_1_1479650735561_3060" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1479650735561_3060" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1479650735561_3060" dir="ltr">It nicely shows that C.Delete selects the "right" module B, i.e. either the "old B" (here called B*), or the "new B" (here called B). The type descriptors and the code of module B* (removed from module list) is still available in memory.</div><div id="yui_3_16_0_ym19_1_1479650735561_3060" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1479650735561_3060" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1479650735561_3060" dir="ltr">All type tests automatically select the "right" type descriptor and the "old B" is only removed from memory when no more references from the remaining modules exist.</div><div id="yui_3_16_0_ym19_1_1479650735561_3060" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1479650735561_3060" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1479650735561_3060" dir="ltr">Andreas</div><div id="yui_3_16_0_ym19_1_1479650735561_3060" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1479650735561_3060" dir="ltr"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3846">COMMAND SEQUENCE (see below for source code of A, B, and C):</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3847"><br id="yui_3_16_0_ym19_1_1479650735561_3848"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3849">B.Insert 1 ... insert elemt from old B</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3850">System.ShowModules ... B is the old B</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3851">System.Free B/f ... remove old B from module list, don't release memorz</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3852">System.ShowModules ... B* is the old B</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3853">B.Insert 2 ... new B</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3854">System.ShowModules ... B* is the old B, B is the new B</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3855">C.Delete 1 ... deletes the element created by the old B</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3856">C.Delete 2 ... deletes the element created by the old B</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3856">C.Init ... clears the data structure rooted in A.root</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3856">Modules.Collect ... collects B* (no longer referenced)</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3856">System.ShowModules ... module B* no longer in memory<br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3857"><br id="yui_3_16_0_ym19_1_1479650735561_3858"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3859">GENERATED OUTPUT:</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3860"><br id="yui_3_16_0_ym19_1_1479650735561_3861"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3862">1) B.Insert 1</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3863">insert element from module B module descriptor at 000212C0</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3864"><br id="yui_3_16_0_ym19_1_1479650735561_3865"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3866">2) System.ShowModules</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3867">B 000212C0 000213D0 0</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3868">A 00020F60 00020FDC 1</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3869">System 0001CB80 0001D320 0</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3870">...</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3871"><br id="yui_3_16_0_ym19_1_1479650735561_3872"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3873">3) System.Free B/f</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3874">B unloading: removing from module list (references exist)</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3875"><br id="yui_3_16_0_ym19_1_1479650735561_3876"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3877">4) System.ShowModules</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3878">*B 000212C0 000213D0 0 (removed from module list)</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3879">A 00020F60 00020FDC 1</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3880">System 0001CB80 0001D320 0</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3881">...</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3882"><br id="yui_3_16_0_ym19_1_1479650735561_3883"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3884">5) B.Insert 2</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3885">insert element from module B module descriptor at 00021800</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3886"><br id="yui_3_16_0_ym19_1_1479650735561_3887"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3934">6) System.ShowModules</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3935">B 00021800 00021910 0</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3936">*B 000212C0 000213D0 0 (removed from module list)</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3937">A 00020F60 00020FDC 2</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3938">System 0001CB80 0001D320 0</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3939">...</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3940"><br id="yui_3_16_0_ym19_1_1479650735561_3941"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3942">7) C.Delete 1</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3943">type of t is T from module B* module descriptor at 000212C0</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3944"><br id="yui_3_16_0_ym19_1_1479650735561_3945"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3946">8) C.Delete 2</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3947">type of t is T from module B module descriptor at 00021800</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3947"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3947">9) C.Init + Modules.Collect + System.ShowModules</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_4085">B 00021800 00021910 0</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_4087">A 00020F60 00020FDC 2</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_4088">System 0001CB80 0001D320 0</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_4089">...</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3948"><br id="yui_3_16_0_ym19_1_1479650735561_3949"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3948">----------------------------------------------------------------------------------------------------</div><div id="yui_3_16_0_ym19_1_1479650735561_3060" dir="ltr"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3503">MODULE A; (*base module managing data structure of base type T*)</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3504"> TYPE T* = POINTER TO R;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3505"> P* = PROCEDURE (t: T);</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3506"> R* = RECORD i*: INTEGER;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3507"> close*: P;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3508"> next: T</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3509"> END ;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3510"><br id="yui_3_16_0_ym19_1_1479650735561_3511"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3512"> VAR root*: T;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3513"><br id="yui_3_16_0_ym19_1_1479650735561_3514"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3515"> PROCEDURE Find*(i: INTEGER): T;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3516"> VAR t: T;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3517"> BEGIN t := root;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3518"> WHILE (t # NIL) & (t.i # i) DO t := t.next END ;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3519"> RETURN t</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3520"> END Find;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3521"><br id="yui_3_16_0_ym19_1_1479650735561_3522"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3523"> PROCEDURE Insert*(t: T);</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3524"> VAR s: T;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3525"> BEGIN s := Find(t.i);</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3526"> IF s = NIL THEN t.next := root; root := t END</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3527"> END Insert;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3528"><br id="yui_3_16_0_ym19_1_1479650735561_3529"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3530"> PROCEDURE Delete*(i: INTEGER);</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3531"> VAR s, t: T;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3532"> BEGIN t := root; s := t;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3533"> WHILE (t # NIL) & (t.i # i) DO s := t; t := t.next END ;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3534"> IF t # NIL THEN t.close(t);</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3535"> IF t = root THEN root := NIL ELSE s.next := t.next END</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3536"> END</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3537"> END Delete;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3538"><br id="yui_3_16_0_ym19_1_1479650735561_3539"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3540"> PROCEDURE Init*;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3541"> BEGIN root := NIL</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3542"> END Init;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3543"><br id="yui_3_16_0_ym19_1_1479650735561_3544"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3545">BEGIN Init</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3546">END A.</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3547"><br id="yui_3_16_0_ym19_1_1479650735561_3548"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3547">--------------------------------------</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3547"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3547"><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3630">MODULE B; (*client of A, defining extensions of A.T*)</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3631"> IMPORT A, Modules, Texts, Oberon;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3632"> TYPE T* = POINTER TO R;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3633"> R* = RECORD (A.R) j: INTEGER END;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3634"><br id="yui_3_16_0_ym19_1_1479650735561_3635"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3636"> VAR M: Modules.Module;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3637"> W: Texts.Writer;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3638"><br id="yui_3_16_0_ym19_1_1479650735561_3639"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3640"> PROCEDURE Close*(t: A.T);</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3641"> VAR S: Texts.Scanner;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3642"> BEGIN</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3643"> IF (t IS T) & (M # NIL) THEN</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3644"> Texts.WriteString(W, "type of t is T from module "); Texts.WriteString(W, M.name);</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3645"> Texts.WriteString(W, " module descriptor at "); Texts.WriteHex(W, ORD(M));</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3646"> Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf)</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3647"> END</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3648"> END Close;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3649"><br id="yui_3_16_0_ym19_1_1479650735561_3650"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3651"> PROCEDURE Insert*;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3652"> VAR S: Texts.Scanner; t: T;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3653"> BEGIN Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); Texts.Scan(S);</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3654"> IF S.class = Texts.Int THEN NEW(t); t.i := S.i; t.close := Close; A.Insert(t);</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3655"> Texts.WriteString(W, "insert element from module "); Texts.WriteString(W, M.name);</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3656"> Texts.WriteString(W, " module descriptor at "); Texts.WriteHex(W, ORD(M));</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3657"> Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf)</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3658"> END</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3659"> END Insert;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3660"><br id="yui_3_16_0_ym19_1_1479650735561_3661"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3662"> PROCEDURE Init*;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3663"> BEGIN</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3664"> END Init;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3665"><br id="yui_3_16_0_ym19_1_1479650735561_3666"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3667">BEGIN Texts.OpenWriter(W); M := Modules.root;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3668"> WHILE (M # NIL) & (M.name # "B") DO M := M.next END</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3669">END B.</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3669"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3669">--------------------------------------<br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3669"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3669"><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3735">ODULE C; (*tool module*)</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3736"> IMPORT A, Texts, Oberon;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3737"><br id="yui_3_16_0_ym19_1_1479650735561_3738"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3739"> VAR W: Texts.Writer;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3740"><br id="yui_3_16_0_ym19_1_1479650735561_3741"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3742"> PROCEDURE Delete*;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3743"> VAR S: Texts.Scanner;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3744"> BEGIN Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); Texts.Scan(S);</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3745"> IF S.class = Texts.Int THEN A.Delete(S.i) END</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3746"> END Delete;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3747"><br id="yui_3_16_0_ym19_1_1479650735561_3748"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3749"> PROCEDURE Init*;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3750"> BEGIN</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3751"> END Init;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3752"><br id="yui_3_16_0_ym19_1_1479650735561_3753"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3754">BEGIN Texts.OpenWriter(W)</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3755">END C.</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3755"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3755">----------------</div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3755"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1479650735561_3755"><br></div></div></div></div></body></html>