[Oberon] Oberon for a C++ user.
Lars
noreply at z505.com
Fri Nov 11 23:20:25 CET 2016
On Fri, November 11, 2016 9:10 am, Srinivas Nayak wrote:
>> If procvar := Mod.Proc is done automatically while module loading,
>> (through code sitting inside module BEGIN...END)
>> we should have an automatic means of making it NIL while unloading.
>> But...we don't have a place like BEGIN...END to execute when module
>> gets unloaded!
>>
>> Can we have something like this...
>> A procedure UnloadMe() which a module will implement.
>> And when the module is unloaded, UnloadMe() will be called.
>>
>
> Clemens Szypeski in his thesis "Insight ETHOS" discusses on
> "Finalization" in section 2.1.4.
>
Just a heads up to implementers and designers: Finalization, although
seems trivial at first sight, has actually caused some nightmares in
freepascal. It seems simple: you just call a finalization section before
the module is unloaded. However the order of finalization is tricky...
which module do you finalize first? You're going to have hundreds of
modules, in large programs, so how do you decide the order of
finalization?
Looking at it from just one module perspective, it's simple. A one module
program is easy. But a large program with hundreds of modules: care must
be taken to ensure order of unloading is done right, if there is even a
"right" way.
Unfortunately my work with freepascal has seen some serious bugs in
finalization for some reason I cannot remember, I think it was
finalization/initialization sections in a DLL not occurring at the right
times.
Since modules all communicate with each other or pull in code from each
other you can get into tricky conflicts, that were not originally
anticipated. For example if finalization accesses some code in another
module directly or indirectly, what if that module is already freed? Will
the compiler warn you that you are calling code that has already been
unloaded? Or will run time warn you?
More information about the Oberon
mailing list