"static" UFCS

deadalnix deadalnix at gmail.com
Thu Jun 14 08:17:50 PDT 2012


Le 14/06/2012 15:57, Regan Heath a écrit :
> 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.
>
> R
>

Or for the namespace reason. It is a valid point.

But UFCS is no help when it come to name collisions. Actually, it can 
increase it. So it is still unclear to me what is the benefit of « 
static UFCS ».


More information about the Digitalmars-d mailing list