static this

Hasan Aljudy hasan.aljudy at gmail.com
Fri Oct 6 05:53:08 PDT 2006



Max Samuha wrote:
> Two questions to the community:
> 
> 1. The following is obviously a bug?
> 
> class Test
> {
> 	static
> 	{
> 		this(){}; // defined not as static constructor but as
> instance constructor
> 
> 		... more static members here		
> 	}
> }

As Chris already said, static is not really an attribute, it's just 
"static this".

> 
> 2. Why module constructor must be attributed with static? All module
> level methods are already static so the attribute seems to be
> redundant. Make it optional?
> 

I guess the reason is to be consistent. "static this" refers to a static 
constructor, i.e. a constructor that will be called at the beginning of 
the program's start.
Module constructors are static constructors, so "static this" is used.



More information about the Digitalmars-d mailing list