[fpc-devel] initialization order of units
J. Gareth Moreton
gareth at moreton-family.com
Fri Oct 23 01:40:44 CEST 2020
This is just my personal opinion, but I do think that using
"initialization" is risky if it uses anything outside of the unit, and
hence you should minimise any inter-dependencies. If I had to suggest a
concrete workaround, it would be a initialisation routine that you call
manually or as part of an object constructor, although it ends up
requiring a bit more work for those who use the unit.
Sorry I can't be of much more help.
Gareth aka. Kit
On 22/10/2020 22:24, Florian Klämpfl via fpc-devel wrote:
> Am 22.10.20 um 23:04 schrieb Pascal Riekenberg via fpc-devel:
>>> Jonas Maebe via fpc-devel <fpc-devel at lists.freepascal.org> hat am
>>> 22.10.2020 22:28 geschrieben:
>>> On 22/10/2020 21:35, Pascal Riekenberg via fpc-devel wrote:
>>>> Have there been any changes to the initialization order of units in
>>>> last 6 month?
>>>> I have a complex project with multiple units with initialization
>>>> section. And now
>>>> one of those units does not get initialized before it is used by the
>>>> initialization part of
>>>> an other unit. This worked at the beginning of the year!
>>> It might be caused the fix for
>>> https://bugs.freepascal.org/view.php?id=32352. Keep in mind that if
>>> there are uses-cycles via the implementation section, the
>>> order of the involved units is undefined.
>> There it is again: my pet project: Why doesn't pascal allow circular
>> unit references (at least for classes, like forwards)!
>> I like pascal very much but this is the biggest annoyance!
>> You always have to work around this (put multiple classes in one
>> unit, create interface classes, ...). And now this:
>> I have such cycles, but it worked before.
>> I removed this cycles and it worked as expected.
>> Isn't there a way to force the order?
>> Why isn't it initialized first even if the unit is the first after
>> Forms in the program?
>> If there are uses-cycles via the implementation section why doesn't
>> fpc prioritize interface order?
> Basically because of this:
> fpc-devel maillist - fpc-devel at lists.freepascal.org
This email has been checked for viruses by Avast antivirus software.
More information about the fpc-devel