<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    On 15/01/2011 11:09, Torsten Bonde Christiansen wrote:<br>
    <blockquote cite="mid:4D318081.2030602@epidata.dk" type="cite">
      <blockquote
        cite="mid:AANLkTing7sc8AbbVY0JL2crksYi2nkaNMHiUbqSyahQ2@mail.gmail.com"
        type="cite">
        <div class="gmail_quote">
          <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
            0.8ex; border-left: 1px solid rgb(204, 204, 204);
            padding-left: 1ex;"><tt> Is it possible to jump a couple of
              levels in the inherited hierarchy when calling "inherited"
              on a method?</tt> <tt><br>
              <br>
            </tt> </blockquote>
        </div>
        <tt><br>
          Hmm, don't know whether you're the same person or not :), but
          I replied in a stackoverflow question the next day after it
          was asked (see here: <a moz-do-not-send="true"
href="http://stackoverflow.com/questions/4662744/delphi-how-to-call-inherited-inherited-ancestor/4670457#4670457">http://stackoverflow.com/questions/4662744/delphi-how-to-call-inherited-inherited-ancestor/4670457#4670457</a>
          ) and it looked like the host didn't notice :). At least this
          variant seemed to work<br>
        </tt></blockquote>
      <tt><br>
        I'm sorry to say that it is not I who wrote on stackoverflow,
        but could as well have been. Anyways, your solution does not
        really solve the problem, since i will have to introduce a
        HackedParent class and that kinds of defeat the purpose.<br>
        All I really want is to skip to a grandparent class using the
        normal "inherited" functionality. I have tried to look through
        the mailinglist archive, because I seem to remember someone </tt><tt>else

        might have asked this question as well - but I haven't been able
        to find anything (yet).</tt><br>
    </blockquote>
    Here is another "solution" (another hack):<br>
    <br>
    <br>
    program Project1;<br>
    {$mode objfpc}{$H+}<br>
    <br>
    type<br>
    <br>
      { TFoo }<br>
    <br>
      TFoo = class<br>
      protected<br>
        procedure DoHello; virtual;<br>
      end;<br>
    <br>
      { TFooChild }<br>
    <br>
      TFooChild = class(TFoo)<br>
      protected<br>
      end;<br>
    <br>
      { TFooGrandChild }<br>
    <br>
      TFooGrandChild = class(TFooChild)<br>
      protected<br>
        procedure DoHello; override; // to be skipped<br>
      end;<br>
    <br>
      { TFooGreatGrandChild }<br>
    <br>
      TFooGreatGrandChild = class(TFooGrandChild)<br>
      protected<br>
        procedure DoHello; override;<br>
      end;<br>
    <br>
    { TFoo }<br>
    <br>
    procedure TFoo.DoHello;<br>
    begin<br>
      writeln('TFoo');<br>
    end;<br>
    <br>
    { TFooGrandChild }<br>
    <br>
    procedure TFooGrandChild.DoHello;<br>
    begin<br>
      writeln('TFooGrandChild');<br>
      inherited DoHello;<br>
    end;<br>
    <br>
    { TFooGreatGrandChild }<br>
    <br>
    procedure TFooGreatGrandChild.DoHello;<br>
    var<br>
      a: procedure of object;<br>
    begin<br>
      writeln('TFooGreatGrandChild');<br>
      //inherited DoHello;<br>
      TMethod(a).Code := @TFooChild.DoHello;<br>
      TMethod(a).Data:= Self;<br>
      a();<br>
    end;<br>
    <br>
    var<br>
      a: TFoo;<br>
    begin<br>
      a := TFooGreatGrandChild.Create;<br>
      a.DoHello;<br>
      readln;<br>
    end.<br>
    <br>
  </body>
</html>