<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Wed, Jun 12, 2013 at 2:12 AM, Bart <span dir="ltr"><<a href="mailto:bartjunk64@gmail.com" target="_blank">bartjunk64@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
I thought that if I had a subclass that inherited form a parentclass,<br>
and both have a method with the same name (Bar), then the method of<br>
the subclass hid the method of the parentclass, and you could not call<br>
inherited Bar in the subclass.<br>
<br></blockquote></div><br></div><div class="gmail_extra">I see your point, but this question is more to the original designers of Delphi. I tried to look at real life examples from VCL (to find the roots of the "devil" :)) and there are cases when it's unavoidable<br>
<br></div><div class="gmail_extra">- Constructors call inherited no matter whether they're virtual or not. It just feels right to allow this.<br><br></div><div class="gmail_extra">- Message handlers call inherited. Technically they're similar to virtual methods so this is something that should have work even if calling inherited from non-virtual methods is prohibited. <br>
<br></div><div class="gmail_extra">- Any method of ClassA(ClassB) can call inherited ClassB.SomeMethod if it's accidentally has the same name as SomeMethod of ClassA. <br><br></div><div class="gmail_extra">- Most of the cases in the VCL is a kind of "type override: when one inherits from TCollection and want to add own Add with the new type of the item (to be sure no other types will be accepted). So in the body it's basically calling inherited Add with a typecast. <br>
<br></div><div class="gmail_extra">- An interesting case: TRegIniFile = class(TRegistry). There are many methods having the same name, but different parameters list. So, it's more semantic inheritance so if you replace the existing code working with registry, you just have to slightly change actual parameters of the methods called. <br>
</div><div class="gmail_extra"><br></div><div class="gmail_extra">Overall looking at all cases I think this keyword can be considered as a good universal prefix excluding the context of the existing class working with methods and properties. Even looking at the name it has more to do with INHERITance than polymorphism<br>
<br></div><div class="gmail_extra">Max <br></div></div>