new DIP47: Outlining member functions of aggregates

Jonathan M Davis jmdavisProg at gmx.com
Sat Sep 7 21:46:53 PDT 2013


On Saturday, September 07, 2013 10:00:05 Walter Bright wrote:
> Outlining of member functions is the practice of placing the declaration of
> a member function in the struct/class/union, and placing the definition of
> it at global scope in the module or even in another module.
> 
> http://wiki.dlang.org/DIP47

I confess that I really don't like this idea. I think that the separation of 
declarations and definitions is a serious downside of C++ and that it 
negatively impacts code maintenence. And from the recent discussion on this, 
it's clear that quite a few people agree with me.

However, at the same time, there are some folks (like Manu) who really prefer 
to separate the declaration and definitions so that they can just see the 
signatures for an entire class' functions at once without seeing any 
definitions. Personally, I don't think that that's a big deal and that it's far 
better to just use generated documentation for that, but clearly there's not a 
consensus on that.

If this DIP is implemented, I do not expect to ever use it, and I hope to 
never have to deal with code that does (which is ultimately the main reason 
why I think that it would be a problem if this were implemented - eventually, 
I'll have to deal with code that uses it even though I think that it harms 
code maintainibility). But at the same time, I don't know that the fact that 
quite a few of this really don't like this paradigm is enough a reason to deny 
it to those who seem to think that it's of value.

If I had to vote though, I'd vote against this, because I think that it's a 
bad paradigm, and I don't want to deal with it.

On an implementation note, I don't think that #5 is strong enough. I think 
that it should be an outright error if there is a difference between the 
declaration and definition rather than giving one precedence over the other. 
I'd also be inclined to argue that #3 should be thrown out and that parameters 
should be required to match, but it's unfortunately not all that uncommon in 
C++ for folks to not even give parameters names in their declarations, so 
requiring that the parameters match is probably too much, much as I think that 
that they should be required to.

- Jonathan M Davis


More information about the Digitalmars-d mailing list