[fpc-pascal] method-definition

Martin Frb lazarus at mfriebe.de
Fri Dec 15 16:00:11 CET 2023


On 15/12/2023 14:56, Adriaan van Os via fpc-pascal wrote:
> I am puzzled by the syntax rule <method-list> in Chapter 6. Classes of 
> the FreePascal Language Reference (version 3.2.0)
>
> Section 6.1 Class definitions has
>
>     method-definition = [ "CLASS" ] ( function-header | 
> procedure-header | constructor-header | destructor-header ) ";" [ ( ( 
> ( "virtual" | "dynamic" ) [ ";" "abstract" ] ) | "override" | 
> "message" ( integer-constant | string-constant ) ) ";" ] [ 
> call-modifiers ";" ] .
>
> Section 6.6.1 Declaration has:
>
>     method-definition = ( function-header | procedure-header | 
> constructor-header | destructor-header ) ";" method-directives .
>
>     method-directives = ( ( "virtual" | "dynamic" ) [ ";" "abstract" ] 
> | "reintroduce" ";" | "override" ";" | "message" constant-expression ) 
> [ call-modifiers ";" ] .
>
> 2. "reintroduce" is in just one of the two definitions.

Another note: "reintroduce" is given as an alternative to "virtual; 
[abstract;]".

However, a method can be reintroduced, and be virtual/abstract.

program Project1;{$Mode objfpc}
type
   TFoo = class
     procedure Bar; virtual; abstract;
   end;

   TFoo2 = class(TFoo)
     procedure Bar; reintroduce; virtual; abstract;
   end;

begin
end.



More information about the fpc-pascal mailing list