Can someone explain the semantic difference between *1 and *2 please?
procedure A(p: Type1);
begin
inherited; // *1
inherited A(p); // *2
end;?
Mattias

Mailing lists / fpc-pascal / 2003-12
4 messages · 3 people ·
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Can someone explain the semantic difference between *1 and *2 please?
procedure A(p: Type1);
begin
inherited; // *1
inherited A(p); // *2
end;?
Mattias
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.
Hello,
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
1: supporting a delphi bug 2: as you expect Well, the comment to 1 isn't completly true:…
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