new DIP47: Outlining member functions of aggregates

Walter Bright newshound2 at digitalmars.com
Sat Sep 7 20:37:29 PDT 2013


On 9/7/2013 12:43 PM, Andrej Mitrovic wrote:
> On 9/7/13, Walter Bright <newshound2 at digitalmars.com> wrote:
>> http://wiki.dlang.org/DIP47
>
> Your example code:
>
> -----
> struct S {
>      static int mfunc(int a, int b = 5) pure;	// member function declaration
> }
>
> int S.mfunc(int a, int b) pure {	// member function definition
>      ...
> }
> -----
>
> Two things:
>
> 1. Why are you demonstrating static functions and not regular member
> functions (or better yet why not both)?

Because I wanted to point out that you didn't need to put the 'static' in front 
of the definition.


> 2. Why has 'static' been removed at the outlined implementation
> function? It should also be there:
>
> static int S.mfunc(int a, int b) pure {	// member function definition
> }

Why?


> To reiterate, let's not introduce a feature where we can be totally
> lax about what we do at the declaration and implementation site. My
> strong opinion is that the declaration and implementation must
> perfectly match, otherwise you can throw the readability argument out
> the window.

On the other hand, DRY, and I don't recall anyone ever complaining about this in 
C++ outlined members.



More information about the Digitalmars-d mailing list