<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">2013/5/16 Don Clugston <span dir="ltr"><<a href="mailto:dclugston@gmail.com" target="_blank">dclugston@gmail.com</a>></span><br><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">
<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div class="im">On 15 May 2013 23:19, Andrei Alexandrescu <span dir="ltr"><<a href="mailto:andrei@erdani.com" target="_blank">andrei@erdani.com</a>></span> wrote:<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">
I'm not assuming you're proposing this, but I'm clarifying just in case: a member that takes per-instance memory YET always has the same value in all objects would be positively useless. _That_ should at best be an error.<span><font color="#888888"><br>
</font></span></blockquote><div><br></div></div><div>Great! This is exactly my argument. In that case we are actually in agreement. Thats the case I want to disallow.<br></div></div></div></div>
</blockquote></div><br></div><div class="gmail_extra">Why it should be error? Yes, it would be finally redundant, but the redundancy is necessary to keep meta-programming simple.</div><div class="gmail_extra"><br></div><div class="gmail_extra">
<div class="gmail_extra">import std.traits;</div><div class="gmail_extra">struct MyData(T) if (isIntegral!T) {</div><div class="gmail_extra"> T value = 10; // provides default value</div><div class="gmail_extra"> alias value this;</div>
<div class="gmail_extra"> this(T v) { value = v; }</div><div class="gmail_extra">}</div><div><br></div></div><div class="gmail_extra">With 2.062 and earlier, this simple MyData struct did not work when T is non-mutable integer type. To support it, it had been required that checking T is non-mutable and then remove constructor.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">import std.traits;</div><div class="gmail_extra">struct MyData(T) if (isIntegral!T) {</div><div class="gmail_extra"> T value = 10; // provides default value</div>
<div class="gmail_extra"> alias value this;</div><div class="gmail_extra"> static if (!is(T == const) && !is(T == immutable))</div><div class="gmail_extra"> { // necessary for 2.062 and earlier</div><div class="gmail_extra">
this(T v) { value = v; }</div><div class="gmail_extra"> }</div><div class="gmail_extra">}</div><div><br></div><div>This is definitely unnecessary complexity. Why you need this?</div><div><br></div></div><div class="gmail_extra">
D should have ability for writing efficient code, but D should not enforce writing efficient code to users.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Kenji Hara</div></div>