static this sucks, we should deprecate it

Jarrett Billingsley jarrett.billingsley at gmail.com
Wed Jun 3 06:28:15 PDT 2009


On Wed, Jun 3, 2009 at 2:56 AM, BCS <none at anon.com> wrote:
> Hello Don,
>
>> You could relax the rule: Even if modules A and B both have 'static
>> this', there is no circular dependency if:
>> (1) throughout the whole of module A, it only uses pure functions from
>> module B.
>> OR
>> (2) if the constructor of module A doesn't directly access static
>> variables of module B, and EVERY function it calls is pure.
>> But that probably doesn't open up very many use cases.
>>
>
> or (3) the compiler can prove no dependency exists. Yes this gets into some
> interesting "Is is illegal code" issues but...

I never quite understood why it couldn't just do this already.  Rarely
in static this() do I access members from other modules; I'm usually
creating singleton instances or initializing AAs or other such mundane
tasks.  Even if the compiler doesn't know whether or not other modules
have a static this() (i.e. when using a .di file), it can at least
tell when a given module _doesn't_ depend on others for its
initialization.



More information about the Digitalmars-d mailing list