Fixing cyclic import static construction problems
Daniel Murphy
yebblies at nospamgmail.com
Thu Nov 29 05:09:10 PST 2012
"Walter Bright" <newshound2 at digitalmars.com> wrote in message
news:k96hj2$2lus$1 at digitalmars.com...
> For discussion:
>
> Cyclical Imports
>
> Problem:
>
>
> Proposed Solution:
>
> Add a pragma,
>
> pragma(cyclic_imports);
>
> This can appear anywhere in a module, and applies globally to that module.
> It means that static constructors from imports that are not part of the
> cycle
> are run first, and that the static constructor for this module may be run
> before
> the static constructors of other modules that are part of the cycle.
>
I don't think this is sufficient. Imagine a group of modules that really
_do_ have a cyclic dependency, and a mixin that adds an independent static
this. Ideally you'd be able to mark the mixed-in constructor as independent
without tainting the whole module.
So just make the pragma apply to declarations, you either mark specific
functions (which can then be mixed in) or put `pragma(...):` at the top of
your module and you get your behaviour.
More information about the Digitalmars-d
mailing list