Fixing cyclic import static construction problems

foobar foo at bar.com
Fri Nov 30 06:09:47 PST 2012


On Thursday, 29 November 2012 at 23:02:17 UTC, Walter Bright 
wrote:
> On 11/30/2012 9:43 AM, Walter Bright wrote:
>> It is possible for each static constructor to specify 
>> independently of
>> the other static constructors which imports must be 
>> constructed first.
>> But do we really want to go that far?
>
> One way to do that might be to borrow syntax from classes:
>
>    static this() : std.stdio, a, c
>    {
>        ...
>    }
>
> and the  this static constructor only requires that modules 
> std.stdio, a, and c be constructed first.
>
>    static this() : void
>    {
>        ...
>    }
>
> means it has no dependencies on other imports.
>
>    static this()
>    {
>       ...
>    }
>
> has the current behavior (all imported modules must be 
> constructed first).

Why not simplify?

static this()
{
import std.stdio, a, c; // existing syntax
    ...
}

static this()
{ // no imports -> no dependencies
    ...
}

The current behavior should just be dropped.


More information about the Digitalmars-d mailing list