UFCS for D

Walter Bright newshound2 at digitalmars.com
Thu Mar 29 16:46:24 PDT 2012


On 3/29/2012 4:34 PM, Steven Schveighoffer wrote:
> One
> misleading suggestion from the article however, it's not very easy to create
> non-friend non-member functions using UFCS, considering that every function in a
> given module is a friend. In order to do this, you would need a helper module
> for each module that wants to define such non-friend functions. Given the above
> proof, the helper module would also have to be imported by the main module.

I think there's a misunderstanding. The class should contain, as member 
functions, anything that needs to access private state. UFCS functions declared 
in other modules should not need access to private state (if they do, it's an 
error in the design of the class) and so should have no problem being non-friends.



More information about the Digitalmars-d-announce mailing list