Fixing cyclic import static construction problems
Manfred Nowak
svv1999 at hotmail.com
Thu Nov 29 04:58:11 PST 2012
Walter Bright wrote:
> It means that [...] the static constructor for this
> module may be run before
This is sufficient only for a simple cycle without any branches
or a trivial clique like the one shown. Please recall, that in a
clique every member is connected to every other member---in this
case by an import statement.
It is already not sufficient for a simple clique consisting of
three modules, because now orderinh would be given for the
remaining two modules.
And it is ambiguous if both of the modules in the example given
are marked with that pragma.
In general a topological sorting has to be specified for all
strongly connected components of the graph of imports.
This cannot be done within the module, because this would bind
the module to that special strongly connected component in that
special set of modules. Which in turn would destroy reusability
of the module for other programming tasks.
Therefore: marking with a pragma isn't a fix for the depicted
problem.
-manfred
More information about the Digitalmars-d
mailing list