<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-18241482.post554983218826600840..comments</id><updated>2009-04-27T09:38:32.693-07:00</updated><title type='text'>Comments on Programming and Debugging (in my Underhøøsen): Static ctors in D.NET (Part 2)</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://the-free-meme.blogspot.com/feeds/554983218826600840/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/18241482/554983218826600840/comments/default'/><link rel='alternate' type='text/html' href='http://the-free-meme.blogspot.com/2009/04/static-ctors-in-dnet-part-2.html'/><author><name>The Free Meme</name><uri>http://www.blogger.com/profile/08287129746971472910</uri><email>cristi.vlasceanu@gmail.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-18241482.post-3393840981323375828</id><published>2009-04-27T09:38:00.000-07:00</published><updated>2009-04-27T09:38:00.000-07:00</updated><title type='text'>I think that there is a small confusion here: what...</title><content type='html'>I think that there is a small confusion here: what I said about static constructors being called only when there is a reference applies to CLASSES.&lt;br /&gt;&lt;br /&gt;The static constructor of a MODULE is always executed. Your example will work without the need for a static module dtor.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/18241482/554983218826600840/comments/default/3393840981323375828'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/18241482/554983218826600840/comments/default/3393840981323375828'/><link rel='alternate' type='text/html' href='http://the-free-meme.blogspot.com/2009/04/static-ctors-in-dnet-part-2.html?showComment=1240850280000#c3393840981323375828' title=''/><author><name>The Free Meme</name><uri>http://www.blogger.com/profile/08287129746971472910</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='05942387056293398693'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://the-free-meme.blogspot.com/2009/04/static-ctors-in-dnet-part-2.html' ref='tag:blogger.com,1999:blog-18241482.post-554983218826600840' source='http://www.blogger.com/feeds/18241482/posts/default/554983218826600840' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-18241482.post-3430042698812948932</id><published>2009-04-25T13:17:00.000-07:00</published><updated>2009-04-25T13:17:00.000-07:00</updated><title type='text'>I have a few project in mind where a static constr...</title><content type='html'>I have a few project in mind where a static constructor is used to inject code into the main program. That way the nothing needs be done except link the a module to effect somthing:&lt;br /&gt;&lt;br /&gt;module main;&lt;br /&gt;&lt;br /&gt;void function(Context)[char[]] actions;&lt;br /&gt;&lt;br /&gt;void main(char[][] args)&lt;br /&gt;{&lt;br /&gt;   Context cx;&lt;br /&gt;   foreach(arg; args[1..$])&lt;br /&gt;     if(auto dg = arg in actions)&lt;br /&gt;        (*dg)(cx);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/////&lt;br /&gt;module plugin;&lt;br /&gt;import main;&lt;br /&gt;&lt;br /&gt;static this()&lt;br /&gt;{&lt;br /&gt;   actions["-plugin"] = function void(Context cx){somthing();};&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;static ~this(){} // just to make things work???</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/18241482/554983218826600840/comments/default/3430042698812948932'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/18241482/554983218826600840/comments/default/3430042698812948932'/><link rel='alternate' type='text/html' href='http://the-free-meme.blogspot.com/2009/04/static-ctors-in-dnet-part-2.html?showComment=1240690620000#c3430042698812948932' title=''/><author><name>BCSd</name><uri>http://www.blogger.com/profile/13116517988033017470</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://the-free-meme.blogspot.com/2009/04/static-ctors-in-dnet-part-2.html' ref='tag:blogger.com,1999:blog-18241482.post-554983218826600840' source='http://www.blogger.com/feeds/18241482/posts/default/554983218826600840' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-18241482.post-8740680458404951630</id><published>2009-04-24T14:48:00.000-07:00</published><updated>2009-04-24T14:48:00.000-07:00</updated><title type='text'>The static ctors are called if a) the class also h...</title><content type='html'>The static ctors are called if a) the class also has a static dtor or b) the class is referenced (either by invoking any of its methods, or accessing its static members).&lt;br /&gt;&lt;br /&gt;The fact that the static ctors of a class that is never actually used are not invoked comes as an optimization. The only reason I would want to do what you are suggesting is to ensure 100% compatibility with the native compiler, but I do not see any benefits in that.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/18241482/554983218826600840/comments/default/8740680458404951630'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/18241482/554983218826600840/comments/default/8740680458404951630'/><link rel='alternate' type='text/html' href='http://the-free-meme.blogspot.com/2009/04/static-ctors-in-dnet-part-2.html?showComment=1240609680000#c8740680458404951630' title=''/><author><name>The Free Meme</name><uri>http://www.blogger.com/profile/08287129746971472910</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='05942387056293398693'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://the-free-meme.blogspot.com/2009/04/static-ctors-in-dnet-part-2.html' ref='tag:blogger.com,1999:blog-18241482.post-554983218826600840' source='http://www.blogger.com/feeds/18241482/posts/default/554983218826600840' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-18241482.post-9200981478335460432</id><published>2009-04-24T14:12:00.000-07:00</published><updated>2009-04-24T14:12:00.000-07:00</updated><title type='text'>Am I reading that correctly in that I can only be ...</title><content type='html'>Am I reading that correctly in that I can only be sure that static constructors will be called if the class also has a static destructor? &lt;br /&gt;&lt;br /&gt;If that is the case, how about make that non-member .cctor touch any class with a static constructor even if it has no destructor. Then they run no mater what.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/18241482/554983218826600840/comments/default/9200981478335460432'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/18241482/554983218826600840/comments/default/9200981478335460432'/><link rel='alternate' type='text/html' href='http://the-free-meme.blogspot.com/2009/04/static-ctors-in-dnet-part-2.html?showComment=1240607520000#c9200981478335460432' title=''/><author><name>BCSd</name><uri>http://www.blogger.com/profile/13116517988033017470</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://the-free-meme.blogspot.com/2009/04/static-ctors-in-dnet-part-2.html' ref='tag:blogger.com,1999:blog-18241482.post-554983218826600840' source='http://www.blogger.com/feeds/18241482/posts/default/554983218826600840' type='text/html'/></entry></feed>