-----BEGIN PGP SIGNED MESSAGE-----
Can somebody explain what the init_module and fini_module fragments are for that I find in every dot-o emitted by GPC and explain how these fragments are called? I can see that something like this would be needed if/when a module has a 'body', but surely, if a module is just a collection of functions ,procedures and bss data (OK I admit my c background), no per-module initialisation or cleanup is required and these fragments shouldn't be necessary (or should just consist of an immeadiate return)?
Loris Caren wrote:
Can somebody explain what the init_module and fini_module fragments are for that I find in every dot-o emitted by GPC and explain how these fragments are called? I can see that something like this would be needed if/when a module has a 'body', but surely, if a module is just a collection of functions ,procedures and bss data (OK I admit my c background), no per-module initialisation or cleanup is required and these fragments shouldn't be necessary (or should just consist of an immeadiate return)?
You're bascially right -- some variables in Pascal do need some initialization (e.g. strings and other schemata), but in some units, there is not initialization required.
What the initializers also do is call the initializers of units used by this one (if any). This is to make sure they are called in the right order (if A uses B, B's initializer should be run before A's one), and that every initializer is run at all (if the main program doesn't use B directly).
This matter is quite hairy due to infelicities in both EP (modules with different implementations) and BP (cyclic unit usage) -- and GPC should even support mixtures of both, and most other ideas we've had would fail on one or both of them.
So for now we're happy if this solution works at all. There's surely room for optimization (as you suggested), but quite frankly, initialization and finalization are not time-critical, so we'd rather not waste our time with it now ...
Frank