On Thu, 31 Mar 2016, silvioprog wrote:

On Thu, Mar 31, 2016 at 11:28 AM, Michael Van Canneyt <
mich...@freepascal.org> wrote:
[...]

I suspect the problem is not in the mode, but in detecting whether a class
is used
or not in a program. It becomes very complicated when you use e.g.
run-time packages.


Hm... so FPC class constructor (or class initialization) works like unit
initialization.

I imagine so, yes.

It is one of the reasons why I don't really see the usefulness of this
construct, except that it looks OOP-ish.

I am guessing it comes from C++/Java/C#, which AFAIK do not have the 
'initialization'
section. But that's just a guess.



Delphi itself is buggy in this regard, and has been since at least D7.
For this reason, in general I advise against extensive use of
initialization sections etc...


Thanks for sharing this information.

It's hard to make test-case when the code has an extensive use of
initialization sections, so currently I'm avoiding it too. However, I need
to register some classes in a class list, so I'm changing my code to do it
in some place like application initialization.

I usually have a 'Start Application' kind of routine where I register all
the necessary things, link things together (needed if you follow 'loosely
coupled' design).

Michael.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to