<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2013/7/2 deadalnix <span dir="ltr"><<a href="mailto:deadalnix@gmail.com" target="_blank">deadalnix@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im">On Tuesday, 2 July 2013 at 08:16:38 UTC, Jonathan M Davis wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">
On Tuesday, July 02, 2013 09:35:38 monarch_dodra wrote:<br>
</div><div class="im"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Coming back from learn here. There was an example where somebody<br>
"accidentally" called a constructor via UFCS. I am kind of<br>
surprised that it worked. I thought UFCS was for functions only,<br>
and that constructors (specifically) were off limits.<br>
<br>
Am I mistaken? Is UFCS explicitly allowed for constructors? Or<br>
did we kind of forget to take it into account?<br>
</blockquote>
<br></div><div class="im">
I'm not sure that it was ever decided one way or the other so much as happened<br>
into being due to how UFCS was implemented. I know that it's come up before,<br>
and folks were arguing on both sides. Personally, I think that it's a horrible<br>
idea.<br>
<br>
- Jonathan M Davis<br>
</div></blockquote>
<br>
We are 2. that is horrible.<br>
</blockquote></div><br></div><div>I don't know what design decision had been there about it.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div>Historically, there's no restriction against UFCS-callable entity.<br>
</div><div>With 2.030 (released on May 11, 2009) and git head, following code completely works.</div><div><br></div><div><div><div>void foo(int[]) {}</div><div>void bar(T)(T) {}</div><div><br></div><div>struct Foo { int[] x; }</div>
<div>struct Bar { this(int[]) {} }</div><div>struct Baz { static opCall(int[]) { return 0; } }</div><div><br></div><div>int[] function(int[]) fp;</div><div>int[] delegate(int[]) dg;</div><div><br></div><div>struct Functor { int opCall(int[]) { return 0; } }</div>
<div>Functor fn;</div><div><br></div><div>void main()</div><div>{</div><div>    fp = function(int[] x){ return x; };</div><div>    dg = delegate(int[] x){ return x; };</div><div><br></div><div>    int[] a;</div><div>    a.foo();</div>
<div>    a.bar();</div><div>    auto x1 = a.Foo();</div><div>    auto x2 = a.Bar();</div><div>    auto x3 = a.Baz();</div><div>    a.fp();</div><div>    a.dg();</div><div>    a.fn();</div><div>}</div></div><div><br></div>
<div>While improvement of dmd front-end code, I didn't touch it.</div><div>Yes, I did never designed it...<br></div></div><div style><br></div><div>Kenji Hara</div></div></div>