On 2012-06-14 15:57, Regan Heath wrote:
Good point. A module level free function in D is essentially a static
class method for /all/ classes in the module. I think people like static
methods over free functions for aesthetic/organisational reasons, not
for functional ones. Except.. if it's a static method then as it's
called with syntax like <class>.<method> it cannot collide with a free
function called <method>. So, perhaps it helps with function lookup and
collisions, much like namespaces do.
What would be the use case for such a feature ?
Assuming;
1. You have no control over the class Foo, nor it's module
2. You don't want private or protected access to Foo's members
Then all you'd get with static UFCS is nicer calling syntax, and
possibly less lookup/collisions, that's it really.
Exactly.
--
/Jacob Carlborg