Program size, linking matter, and static this()
    Jonathan M Davis 
    jmdavisProg at gmx.com
       
    Sat Dec 17 18:01:04 PST 2011
    
    
  
On Saturday, December 17, 2011 19:44:28 deadalnix wrote:
> Very good point. CTFE is improving with each version of dmd, and is a
> real alternative to static this(); It should be considered when
> apropriate, it has many benefices.
I think that in general, the uses for static this fall into one of two 
categories:
1. Initializing stuff that can't be initialized at compile time. This includes 
stuff like classes or AAs as well as stuff which needs to be initialized with a 
value which isn't known until runtime (e.g. when the program started running).
2. Calling functions which need to be called at the beginning of the program 
(e.g. a function which does something to the environment that the program is 
running in).
As CTFE improves, #1 should become smaller and smaller, and static this should 
be needed less and less, but #2 will always remain. It _is_ however the far 
rarer of the two use cases. So, ultimately static this may become very rare.
- Jonathan M Davis
    
    
More information about the Digitalmars-d
mailing list