<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2013/3/14 deadalnix <span dir="ltr"><<a href="mailto:deadalnix@gmail.com" target="_blank">deadalnix@gmail.com</a>></span><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

It is a tempting idea, but do not work. Consider :<br>
<br>
void delegate() immutable a;<br>
const void delegate() b = a;<br>
<br>
This would be forbidden as covariance of function parameters and transitivity act in opposite directions.<br>
</blockquote></div><br></div><div class="gmail_extra">You are misunderstanding about delegate type syntax and transitivity.</div><div class="gmail_extra"><br></div><div class="gmail_extra">1. This qualifier for delegate type should be added after parameter types.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">const void delegate() b;   // bad, typeof(b) == const(void deelgate())<br></div><div class="gmail_extra">void delegate() const b;   // good, b can hold const method</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">2. A delegate which has immutable context cannot implicitly convertible to const context delegate.</div><div class="gmail_extra"><br></div><div class="gmail_extra">
In general, if a delegate can implicitly convertible to another, there should be _contravariance_ of parameter types.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">void delegate() immutable a;<br></div>
<div class="gmail_extra">void delegate() const b;</div><div class="gmail_extra">b = a;  // bad<br></div><div class="gmail_extra">a = b;  // good</div><div class="gmail_extra"><div><br></div><div>Kenji Hara</div></div></div>