link error for 2+ static this()
    BCS 
    BCS at pathlink.com
       
    Wed Jun  7 09:05:20 PDT 2006
    
    
  
This is the behavior I would expect. If there is some sort of technical 
problem with multiple constructors than how can you have several static 
class constructors? I would expect that whatever is done to sequence 
these would be trivially expendable to module constructors.
I would like to see this ability. in some cases it would greatly improve 
the readability of code.
Example:
<code>
int[] someStaticDataSet;
static this(){/* set up someStaticDataSet */ }
int useThis(int i){/* function uses someStaticDataSet */ return value;}
Object[int] someStaticAA;
static this(){/* seeds someStaticAA */ }
bool PutThere(Object o, int i)
	{/* function uses someStaticAA */ return false;}
Object GetThat(int i)
	{/* function uses someStaticDataSet */ return obj;}
</code>
Lumping the two constructors together serves no purpose from a 
readability standpoint.
Johan Granberg wrote:
> Derek Parnell wrote:
> 
>> It doesn't for me. I thought that meant that if one has more than one 
>> static constructor in a module then they run in lexical order. For 
>> example ....
>> ...
>> --Derek Parnell
>> Melbourne, Australia
> 
> 
> Ok in that case dmd and gdc have implemented this differently
> 
> this code compiled with gdc-0.18
> 
> //begin test.d
> uint a=0,b=0;
> static this()
> {
>     a=1;
> }
> static this()
> {
>     b=2;
> }
> void main()
> {
>     printf("%i, %i\n",a,b);
> }
> //end test.d
> prints this
> 1, 2
    
    
More information about the Digitalmars-d-bugs
mailing list