Inheritance of purity

deadalnix deadalnix at
Sat Feb 18 04:34:13 PST 2012

Le 17/02/2012 04:54, Jonathan M Davis a écrit :
> On Thursday, February 16, 2012 19:41:00 Walter Bright wrote:
>> On 2/16/2012 7:23 PM, Jonathan M Davis wrote:
>>> No. Absolutely not. I hate the fact that C++ does this with virtual. It
>>> makes it so that you have to constantly look at the base classes to
>>> figure out what's virtual and what isn't. It harms maintenance and code
>>> understandability. And now you want to do that with @safe, pure, nothrow,
>>> and const? Yuck.
>> I do not see how it harms maintainability. It does not break any existing
>> code. It makes it easier to convert a function hierarchy to nothrow, pure,
>> etc.
> It makes it harder to maintain the code using the derived classes, because you
> end up with a bunch of functions which aren't labeled with their attributes.
> You have to go and find all of the base classes and look at them to find which
> attributes are on their functions to know what the attributes of the functions
> of the derived classes actually are. It will make using all D classes harder.
> You should be able to look at a function and know whether it's pure, @safe,
> nothrow, or const without having to dig through documentation and/or code
> elsewhere to figure it out.
> Doing this would make the conversion to const easier but be harmful in the
> long run.
> - Jonathan M Davis

As long as the overriden keyword is specified, you are warned about 
this, and so it isn't a problem.

Obviously, this shouldn't apply to override that are not explicitely 
marked as such (with overriden keyword).

More information about the Digitalmars-d mailing list