<div class="gmail_quote">On Thu, Jun 9, 2011 at 1:32 AM, Jonathan M Davis <span dir="ltr"><<a href="mailto:jmdavisProg@gmx.com">jmdavisProg@gmx.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;">

<div><div></div><div class="h5">On 2011-06-09 01:15, Andrew Wiley wrote:<br>
> On Thu, Jun 9, 2011 at 12:46 AM, Jonathan M Davis<br>
<<a href="mailto:jmdavisProg@gmx.com">jmdavisProg@gmx.com</a>>wrote:<br>
> > On 2011-06-09 00:20, Andrew Wiley wrote:<br>
> > > On Wed, Jun 8, 2011 at 12:41 PM, Alex_Dovhal <<a href="mailto:alex_dovhal@yahoo.com">alex_dovhal@yahoo.com</a>><br>
> ><br>
> > wrote:<br>
> > > > There have been several topics discussing UFCS recently. So here is<br>
> > > > one 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>
> > > ><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>
> > > ><br>
> > > >    a.func(@, b) or b.func(a, @);<br>
> > > ><br>
> > > >  * UFCS can be used for more than one argument: a.func(@_, @_~[1]);<br>
> > > ><br>
> > > > What do you think?<br>
> > ><br>
> > > I find it funny that @ was initially adopted for annotations, to be<br>
> > > used similar to Java and Scala. I come from that world, and one of the<br>
> > > rules<br>
> ><br>
> > for<br>
> ><br>
> > > annotations is that they cannot directly alter the code the compiler<br>
> > > outputs. You can add plugins to the Java compiler that use annotations<br>
> > > to modify the AST before it's compiled, and you can use annotations<br>
> > > for runtime bytecode generation or interpret them using reflection,<br>
> > > but if<br>
> ><br>
> > you<br>
> ><br>
> > > take unannotated code and annotated code and compile it (without<br>
> > > altering the compiler), the generated code will not change.<br>
> > > The idea was to make them a part of the language composed entirely of<br>
> > > metadata (some of which was enforced to be correct by the compiler)<br>
> > > that could be completely ignored if the programmer didn't want to use<br>
> > > it. Now that D has taken up this syntax, we've done almost the<br>
> > > opposite. @ is mostly used in situations where it changes the compiled<br>
> > > code, changes the existing language,  and is in no way optional. We<br>
> > > don't really support<br>
> ><br>
> > user<br>
> ><br>
> > > defined metadata, and we can't use what annotations we have as metadata<br>
> > > because only the compiler can actually use it. Most of the uses I've<br>
> > > seen seem to be a way to cram more keywords into the language without<br>
> > > adding more keywords.<br>
> > > I've been holding in this sort of rant for a while, but in summary, my<br>
> > > response is that unless the desired use for @ was defined radically<br>
> > > differently by D when it was adopted (and, as far as I can tell, it<br>
> > > wasn't), seeing another abuse of it just makes me feel slightly sick<br>
> > > inside.<br>
> ><br>
> > As it is, user-defined attributes can be added later using the @ syntax.<br>
> > True,<br>
> > all of the current uses of @ are for where we decided to save a keyword,<br>
> > but<br>
> > that doesn't stop user-defined attributes from using the syntax later. It<br>
> > just<br>
> > means that those that are currently defined will always be special.<br>
><br>
> This is the difference in philosophy at the core of my general unhappiness.<br>
> When Java officially added annotations, they were designed and built to be<br>
> used for user-defined metadata. We added "Property" to the grammar,<br>
> celebrated that we had them too, then stopped. The result is that we're<br>
> throwing around @ as an excuse for language keywords and boasting about how<br>
> we have annotations when, by the definition of any other language, we<br>
> simply don't.<br>
> I guess the best answer from where I'm standing is to start throwing around<br>
> possible syntaxes for annotation declarations and references to them in<br>
> compile-time reflection. I just really hope this gets in to D2, so we<br>
> aren't permanently stuck with "fake annotations."<br>
<br>
</div></div><p>I don't really see anything wrong with leaving the current @ attributes as<br>
they are and then just using @ for user-defined attributes as well. There will<br>
just be a set of attribute names which are reserved by the compiler. All that<br>
using a different syntax for user-defined attributes would buy you would be<br>
that you could use the attribute names that the compiler has reserved - safe,<br>
trusted, system, and property. And that isn't exactly a huge gain. We might as<br>
well just use @ for user-defined attributes as well.</p></blockquote><div> </div><div>My point wasn't that the syntax should be different (it should definitely be the same), my point was that we stopped short of fully implementing annotation support and that the result seems to be significantly less than ideal.</div>

<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;"><p> </p></blockquote></div>