On Friday, 9 March 2012 at 23:50:50 UTC, bearophile wrote:
At first I didn't like it a lot because it's cheap syntax sugar that adds no new power and gives programmers more freedom to write different-looking versions of the the same code (and this is often bad).
What I like about is the encapsulation benefits. You don't have to know if the function is a method or an external function, it just works. External, non-friend (so separate module in D) functions are often preferable to methods because they don't have access to the class' private members, so they cannot rely on those implementation details. Extending objects with new functions in this way also means you don't break binary compatibility with the existing code, since it isn't modified at all! Of course, you could always do this with the old syntax too, but then the syntax preference means you are biased toward one implementation or the other - it doesn't mesh as well and you may be tempted to make things methods for the syntax, despite the cost in compatibility. UFCS rox.