[Issue 6856] Preconditions are not inherited

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 3 07:27:14 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6856



--- Comment #13 from Leandro Lucarella <llucax at gmail.com> 2011-11-03 07:26:39 PDT ---
(In reply to comment #12)
> (In reply to comment #10)
> > (In reply to comment #9)
> > > This explicit widening of preconditions of virtual functions seems to be a
> > > really niche feature.
> > 
> > I think it does makes some sense to be like this. You can see it as adding an
> > extra method to a derived class, or class implementing an interface. 
> 
> Yes. But in those cases you mention, the syntax for accessing the base
> functionality is different to the derived functionality. But here we have
> something different:
> 
>     Derived c;
>     Base b = c;
>     c.foo(7); // OK
>     b.foo(7); // fail -- precondition is not widened
> 
> Same function body gets used in both calls, BUT different contracts need to get
> called.

I still don't see how that's wrong. I can understand it could be awful to
implement. And I can even agree that it doesn't worth the trouble. But the code
it self makes sense to me.

> > The
> > derived class adding a new method() still satisfies the interface, in the same
> > sense an overriden method accepting wider preconditions still satisfies the
> > original precondition, and the interface.
> 
> Yes, it does, but why is that desirable? When do you actually want that? Only
> in niche cases, I think.

Yes, that's probably true. But if it's something easy to do, I see the sense on
having the feature. If it's extremely hard I agree it might not worth it.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list