static this sucks, we should deprecate it

Robert Fraser fraserofthenight at gmail.com
Thu May 28 12:29:42 PDT 2009


Steven Schveighoffer wrote:
> On Thu, 28 May 2009 08:14:45 -0400, Frank Benoit 
> <keinfarbton at googlemail.com> wrote:
> 
>> Unknown W. Brackets schrieb:
>>> Probably a silly idea, but what about (or similar):
>>>
>>> static this: mod.name, mod.name2, mod.name3
>>> {
>>> }
>>>
>>> For a dependency list.  I may be wrong, but afaik the main problems stem
>>> from either wrong order or co-dependence (which needs to be solved by
>>> the programmer.)
>>>
>>> At least with this, you could ask the compiler for an order,
>>> potentially.  If the other modules had no static this, it could ignore
>>> it, allowing future proofing.
>>>
>>> But, maybe that's an ugly hack.
>>>
>>> -[Unknown]
>>>
>>
>> In Java the
>> static { /* static ctor code */ }
>> does not have the circular dependency problem. why is that?
> 
> Probably because Java doesn't use source code as imports.  It is one 
> flaw of D that I really wish could be fixed.
> 
> -Steve

That's not strictly true; a .java file is the compilation unit, which 
can contain any number of classes (only one public, but any # of 
inner/package-protected ones).



More information about the Digitalmars-d mailing list