<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Sep 2, 2013 at 10:11 PM, monarch_dodra <span dir="ltr"><<a href="mailto:monarchdodra@gmail.com" target="_blank">monarchdodra@gmail.com</a>></span> wrote:<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, 3 September 2013 at 04:15:17 UTC, Timothee Cour wrote:<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">
I'd like to be able to declare a function with a special @mixin property<br>
that will auto-mixin at call site<br>
</blockquote>
<br></div>
Kenji had apparently implemented this:<br>
<a href="https://github.com/D-Programming-Language/dmd/pull/459" target="_blank">https://github.com/D-<u></u>Programming-Language/dmd/pull/<u></u>459</a><br>
<br>
But pulled out. This recent thread should sum it up:<br>
<a href="http://forum.dlang.org/thread/yaasjclvyobpeftgwmke@forum.dlang.org" target="_blank">http://forum.dlang.org/thread/<u></u>yaasjclvyobpeftgwmke@forum.<u></u>dlang.org</a></blockquote><div><br></div><div>The last comment from Andrei in <a href="https://github.com/D-Programming-Language/dmd/pull/459">https://github.com/D-Programming-Language/dmd/pull/459</a> is actually rather supportive of such feature, and seemed to encourage a more thorough discussion which never happened (AFAIK).</div>
<div>And unlike what is said in the thread above (last comment), the feature indeed was implemented already, but not merged.</div><div><br></div><div> </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">

Long story short, you are basically asking for macro. If we<br>
allowed this, than anything could actually be code injection, and<br>
mean anything.</blockquote><div><br></div><div>No, only mixin statements and @mixin functions. And a regular function calling a @mixin function would still be regular, eg not able to access symbols in enclosing scope by name.</div>
<div>Given that properties can be queried at compile time, there is no ambiguity. Proper tooling can reveal which statements are mixins if needed (which doesn't imply that the language readability depends on having an IDE). </div>
<div> </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">
<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">
If for some reason we can't have @mixin special property, can we at least<br>
have UFCS for mixin, so that we could write:<br>
"variables: x1=$x1, x2=$x2, sum=$(x1+x2)".embed.mixin<br>
</blockquote>
<br></div>
I'm not sure this us very interesting (why not though), since<br>
nothing would ever come after the mixin.<br></blockquote><div><br></div><div>What do you mean by "nothing would ever come after the mixin" ?</div><div><div>You can have: some_string.embed.mixin.writeln;</div></div>
<div><br></div><div>Simple use case:</div><div>or: assert(foo(x)==bar(y), "error with $(foo(x)) and $(bar(y)) ".embed);<br></div><div><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">

I'd still rather have "typeof" be UFCS-able:<br>
5.typeof.stringof.writeln();<br>
<br>
If we only got to choose 1 that is ;)<br></blockquote><div><br></div><div>Features should be orthogonal unless there's a good reason not to. IMO, assert, typeof, mixin, etc should all be UFCS-able. But this has been brought up many times before.</div>
<div><br></div></div></div></div>