static this sucks, we should deprecate it

Don nospam at nospam.com
Wed Jun 3 21:24:27 PDT 2009


BCS 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...
> 
No.
The problem with that is that it's a nightmare for portability. Code 
which will work fine on compiler A, won't compiler on compiler B.

You'd have to precisely define which scenarios are allowed. The two I 
proposed are simple cases where it can prove no dependency exists. No 
doubt there are many more.



More information about the Digitalmars-d mailing list