Inheritance of purity
Timon Gehr
timon.gehr at gmx.ch
Sat Feb 25 09:57:54 PST 2012
On 02/25/2012 06:53 PM, deadalnix wrote:
> Le 25/02/2012 12:40, Timon Gehr a écrit :
>> On 02/24/2012 01:41 PM, deadalnix wrote:
>>> Le 18/02/2012 19:25, Walter Bright a écrit :
>>>> On 2/18/2012 6:49 AM, kenji hara wrote:
>>>>> After some thoughts, I agree that inheritance of pure @safe, and
>>>>> nothrow is good feature.
>>>>> But I disagree to const inference, because const attribute interacts
>>>>> with overloadings.
>>>>
>>>> The const inheritance *only* happens if otherwise you'd get a
>>>> covariance
>>>> error. It does not change the meaning of any existing code that
>>>> compiled
>>>> successfully.
>>>
>>> yes but then, if a method is added to the base class, you will have a
>>> changement of behavior of all overriden method, silently.
>>>
>>
>> No. The compiler will explode in your face.
>>
>
> class A {
> void fun() const { ... }
> }
>
> class B : A {
> override void fun() { ... }
> }
>
> Now I change the class A to become :
>
> class A {
> void fun() const { ... }
> void fun() { ... }
> }
>
> And suddenly, the override doesn't override the same thing anymore.
> Which is unnacceptable.
You didn't try to actually compile this, did you? ;D
More information about the Digitalmars-d
mailing list