<div class="gmail_quote">On Wed, Jun 8, 2011 at 12:41 PM, Alex_Dovhal <span dir="ltr"><<a href="mailto:alex_dovhal@yahoo.com">alex_dovhal@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

There have been several topics discussing UFCS recently. So here is one<br>
more)<br>
One idea about UFCS - mark UFCS argument with @, @_, or _ symbol,<br>
e.g. you have some function:<br>
void func(Type1 p1, Type2 p2);<br>
<br>
and later call it:<br>
fucn(a, b);  //or<br>
a.func(@_, b);  //or<br>
b.func(a, @_);<br>
<br>
This way Timon Gehr's example:<br>
    take(10,stride(2,cycle([3,2,5,3])));<br>
    [3,2,5,3].cycle().stride(2).take(10);<br>
would be written as this:<br>
    [3,2,5,3].cycle(@_).stride(2, @_).take(10, @_);<br>
<br>
Which is a little longer. On the other side this way benefits from:<br>
 * UFCS is directly seen by both the programmer and compiler;<br>
 * UFCS doesn't mix with member call syntax;<br>
 * UFCS can be used for any type and for any argument, e.g.<br>
    a.func(@, b) or b.func(a, @);<br>
 * UFCS can be used for more than one argument: a.func(@_, @_~[1]);<br>
<br>
What do you think?<br>
<br>
<br>
</blockquote></div><br><div><br></div><div>I find it funny that @ was initially adopted for annotations, to be used similar to Java and Scala. I come from that world, and one of the rules for annotations is that they cannot directly alter the code the compiler outputs. You can add plugins to the Java compiler that use annotations to modify the AST before it's compiled, and you can use annotations for runtime bytecode generation or interpret them using reflection, but if you take unannotated code and annotated code and compile it (without altering the compiler), the generated code will not change.</div>

<div>The idea was to make them a part of the language composed entirely of metadata (some of which was enforced to be correct by the compiler) that could be completely ignored if the programmer didn't want to use it.</div>

<div>Now that D has taken up this syntax, we've done almost the opposite. @ is mostly used in situations where it changes the compiled code, changes the existing language,  and is in no way optional. We don't really support user defined metadata, and we can't use what annotations we have as metadata because only the compiler can actually use it. Most of the uses I've seen seem to be a way to cram more keywords into the language without adding more keywords.</div>

<div>I've been holding in this sort of rant for a while, but in summary, my response is that unless the desired use for @ was defined radically differently by D when it was adopted (and, as far as I can tell, it wasn't), seeing another abuse of it just makes me feel slightly sick inside.</div>