[Oberon] Oberon for a C++ user.

Andreas Pirklbauer andreas_pirklbauer at yahoo.com
Sat Oct 1 13:54:01 CEST 2016


Chris, Joerg:that is exactly the problem: assigning a procedure of a *client* module to a procedure variable of an *imported* module, and then unloading the client module - leaving the procedure variable in the imported module dangling.Assigning a procedure of a client module to a variable of an imported "base" module is in fact the standard way the Oberon system itself employs procedure variables to implement the viewer system in an object-oriented style.For example, module TextFrames (the client) installs a handler (procedure TextFrames.Handle) in the field F.handle of text frame F (see TextFrames.NewText and TextFrames.Open for the details), where the record field F.handle is declared as a procedure variable in the "base" module Viewers (see Viewers.ViewerDesc), which also manages the viewer data structure (see procedure Viewers.Open). Except that of course in the case of the Oberon system, the "client" module TextFrames *never* gets unloaded, so this is not a problem there. Thus, the burden is on the user to make sure that such modules never get unloaded.It is of course possible to implement a "procedure variable" counter - in analogy to the "module counter" employed in Oberon: each time an assignment to a procedure variable is made, the counter gets increased. But that would require changing the code generator compiler for assignments, and the module loader (Modules.Load) and unloader (Modules.Free). But I would refrain from introducing such complexity to the compiler and runtime system.Andreas
Chris Burrows chris at cfbsoftware.com 

> Joerg,
>
> OK - you may well be onto something here but it is incomplete as it is. Something has to> import Square so that the module body is executed, or you need an exported procedure in> Square that is called from the OS. >
> Note: there are a couple of semicolons missing and Init must be exported.>
> Chris.

> -----Original Message-----
> From: Jörg Straube [mailto:joerg.straube at iaeth.ch]
> Sent: Saturday, 1 October 2016 2:22 PM
> To: chris at cfbsoftware.com; ETH Oberon and related systems
> Subject: Re: [Oberon] Oberon for a C++ user.
> 
> Chris
> 
> Here a possble example that might cause issues:
> 
> MODULE Figure;
> TYPE
>   DrawProc = PROCEDURE;
>   Figure = POINTER TO FigureDesc;
>   FigureDesc = RECORD
>     next: Figure;
>     draw: DrawProc
>   END;
> VAR list: Figure;
> PROCEDURE Init(d: DrawProc)
>   VAR f: Figure;
>   BEGIN
>     NEW(f); f.next := list; list := f;
>     f.draw := d
>   END Init;
> BEGIN list:= NIL END Figure.
> 
> MODULE Square;
> IMPORT Figure;
> PROCEDURE DrawSquare;
>   BEGIN (* do what ever you
>     need to do to draw a square *)
>   END DrawSquare
> BEGIN
>   Figure.Init(DrawSquare)
> END Square.
> 
> Now you could run Square and unload Square. The list in Figure has a
> reference to unloaded code.
> 
> J rg
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20161001/1e0f1c53/attachment.html>


More information about the Oberon mailing list