5.5.1 Declaration

The declaration of a method is much like a normal function or procedure declaration, with some additional specifiers, as can be seen from the following diagram, which is part of the object declaration:

_________________________________________________________________________________________________________
methods

--              --     -----            ---- -              ----
  method definition --class--| - function header --|;  method directives
                          -pcrooncstedruucrteo hre haeadderer-|
                          -destructor header-|

--              -------------------------------------------------
  method directives - virtual- ;---------------| -call modifiers ;-|
                             -abstract -;--|
___________________________________________________________________

from the point of view of declarations, Method definitions are normal function or procedure declarations. Contrary to TP and Delphi, fields can be declared after methods in the same block, i. e. the following will generate an error when compiling with Delphi or Turbo Pascal, but not with FPC:

Type  
  MyObj = Object  
    Field : Longint;  
    Procedure Doit;  
  end;