Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2003-12

inherited keyword

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mattias Gaertner

Can someone explain the semantic difference between *1 and *2 please?

procedure A(p: Type1);
begin
  inherited; // *1
  inherited A(p); // *2
end;

?

Mattias

Reply by email

Florian Klaempfl
to Mattias Gaertner
Mattias Gaertner wrote 9 lines
Can someone explain the semantic difference between *1 and *2 please? procedure A(p: Type1); begin inherited; // *1 inherited A(p); // *2 end; ?

1: supporting a delphi bug
2: as you expect

Well, the comment to 1 isn't completly true: In method handlers (declared with message XXX), a simply inherited should pass the message to the parent message handle while in usual methods it does nothing.

Reply by email

Thomas Schatzl
to Florian Klaempfl

Hello,

Show quoted text 16 lines
> Can someone explain the semantic difference between *1 and *2 please? > > procedure A(p: Type1); > begin > inherited; // *1 > inherited A(p); // *2 > end; > > ? 1: supporting a delphi bug 2: as you expect Well, the comment to 1 isn't completly true: In method handlers (declared with message XXX), a simply inherited should pass the message to the parent message handle while in usual methods it does nothing.

According to the D7 docs both types of syntaxes (sp?) are completely legal and defined such that both terms are semantically equal.

---- snip from D7 docs:

The reserved word inherited plays a special role in implementing polymorphic behavior. It can occur in method definitions, with or without an identifier after it.

If inherited is followed by the name of a member, it represents a normal method call or reference to a property or field--except that the search for the referenced member begins with the immediate ancestor of the enclosing method's class. [Type 2]

[...example omitted...]

When inherited has no identifier after it, it refers to the inherited method with the same name as the enclosing method or, if the enclosing method is a message handler, to the inherited message handler for the same message. In this case, inherited takes no explicit parameters, but passes to the inherited method the same parameters with which the enclosing method was called. [Type 1]

[...example omitted...]

--- snip end

Or am I misinterpreting these few lines?

Probably they [the Borland guys] adapted the docs for buggy behaviour of earlier Delphi versions... =)

Regards,
Thomas

Reply by email

Mattias Gaertner
to Florian Klaempfl: 1: supporting a delphi bug 2: as you expect Well, the comment to 1 isn't completly true:…
Show quoted text 18 lines
Mattias Gaertner wrote: > Can someone explain the semantic difference between *1 and *2 please? > > procedure A(p: Type1); > begin > inherited; // *1 > inherited A(p); // *2 > end; > > ? 1: supporting a delphi bug 2: as you expect Well, the comment to 1 isn't completly true: In method handlers (declared with message XXX), a simply inherited should pass the message to the parent message handle while in usual methods it does nothing.

What do you mean with "it does nothing"? It calls the ancestor method, does it not?

Back to my initial question: It is indeed about a message method. I have got a message method where "inherited;" and "inherited MethodName(Param);" is not always the same. The strange thing is: It depends on how the objects are created.
Is this a bug?

Mattias

Reply by email