Free Pascal
Reference guide


______________________________________________________________________
Reference guide for Free Pascal, version 3.2.2
Document version 3.2.2
June 2021

Michaėl Van Canneyt

____________________________________________________________________________
Contents
List of Tables
 About this guide
  Notations
  Syntax diagrams
 About the Pascal language
1 Pascal Tokens
 1.1 Symbols
 1.2 Comments
 1.3 Reserved words
  1.3.1 Turbo Pascal reserved words
  1.3.2 Object Pascal reserved words
  1.3.3 Modifiers
 1.4 Identifiers
 1.5 Hint directives
 1.6 Numbers
 1.7 Labels
 1.8 Character strings
2 Constants
 2.1 Ordinary constants
 2.2 Typed constants
 2.3 Resource strings
3 Types
 3.1 Base types
  3.1.1 Ordinal types
  3.1.2 Real types
 3.2 Character types
  3.2.1 Char or AnsiChar
  3.2.2 WideChar
  3.2.3 Other character types
  3.2.4 Single-byte String types
  3.2.5 Multi-byte String types
  3.2.6 Constant strings
  3.2.7 PChar – Null terminated strings
  3.2.8 String sizes
 3.3 Structured Types
  3.3.1 Arrays
  3.3.2 Record types
  3.3.3 Set types
  3.3.4 File types
 3.4 Pointers
 3.5 Forward type declarations
 3.6 Procedural types
 3.7 Variant types
  3.7.1 Definition
  3.7.2 Variants in assignments and expressions
  3.7.3 Variants and interfaces
 3.8 Type aliases
 3.9 Managed types
4 Variables
 4.1 Definition
 4.2 Declaration
 4.3 Scope
 4.4 Initialized variables
 4.5 Initializing variables using default
 4.6 Thread Variables
 4.7 Properties
5 Objects
 5.1 Declaration
 5.2 Abstract and sealed objects
 5.3 Fields
 5.4 Class or Static fields
 5.5 Constructors and destructors
 5.6 Methods
  5.6.1 Declaration
  5.6.2 Method invocation
 5.7 Visibility
6 Classes
 6.1 Class definitions
 6.2 Abstract and sealed classes
 6.3 Normal and static fields
  6.3.1 Normal fields/variables
  6.3.2 Class fields/variables
 6.4 Class instantiation
 6.5 Class destruction
 6.6 Methods
  6.6.1 Declaration
  6.6.2 Invocation
  6.6.3 Virtual methods
  6.6.4 Class methods
  6.6.5 Class constructors and destructors
  6.6.6 Static class methods
  6.6.7 Message methods
  6.6.8 Using inherited
 6.7 Properties
  6.7.1 Definition
  6.7.2 Indexed properties
  6.7.3 Array properties
  6.7.4 Default properties
  6.7.5 Published properties
  6.7.6 Storage information
  6.7.7 Overriding and redeclaring properties
 6.8 Class properties
 6.9 Nested types, constants and variables
7 Interfaces
 7.1 Definition
 7.2 Interface identification: A GUID
 7.3 Interface implementations
 7.4 Interface inheritance
 7.5 Interface delegation
 7.6 Interfaces and COM
 7.7 CORBA and other Interfaces
 7.8 Reference counting
8 Generics
 8.1 Introduction
 8.2 Generic type definition
 8.3 Generic type specialization
 8.4 Generic type restrictions
 8.5 Delphi compatibility
  8.5.1 Syntax elements
  8.5.2 Record type restrictions
  8.5.3 Type overloads
  8.5.4 Name space considerations
 8.6 Type compatibility
 8.7 Using the default intrinsic
 8.8 A word about scope
 8.9 Operator overloading and generics
9 Extended records
 9.1 Definition
 9.2 Extended record enumerators
 9.3 Record operators
10 Class, Record and Type helpers
 10.1 Definition
 10.2 Restrictions on class helpers
 10.3 Restrictions on record helpers
 10.4 Considerations for (simple) type helpers
 10.5 A note on scope and lifetime for record and type helpers
 10.6 Inheritance
 10.7 Usage
11 Objective-Pascal Classes
 11.1 Introduction
 11.2 Objective-Pascal class declarations
 11.3 Formal declaration
 11.4 Allocating and de-allocating Instances
 11.5 Protocol definitions
 11.6 Categories
 11.7 Name scope and Identifiers
 11.8 Selectors
 11.9 The id type
 11.10 Enumeration in Objective-C classes
12 Expressions
 12.1 Expression syntax
 12.2 Function calls
 12.3 Set constructors
 12.4 Value typecasts
 12.5 Variable typecasts
 12.6 Unaligned typecasts
 12.7 The @ operator
 12.8 Operators
  12.8.1 Arithmetic operators
  12.8.2 Logical operators
  12.8.3 Boolean operators
  12.8.4 String operators
  12.8.5 Dynamic array operators
  12.8.6 Set operators
  12.8.7 Relational operators
  12.8.8 Class operators
13 Statements
 13.1 Simple statements
  13.1.1 Assignments
  13.1.2 Procedure statements
  13.1.3 Goto statements
 13.2 Structured statements
  13.2.1 Compound statements
  13.2.2 The Case statement
  13.2.3 The If..then..else statement
  13.2.4 The For..to/downto..do statement
  13.2.5 The For..in..do statement
  13.2.6 The Repeat..until statement
  13.2.7 The While..do statement
  13.2.8 The With statement
  13.2.9 Exception Statements
 13.3 Assembler statements
14 Using functions and procedures
 14.1 Procedure declaration
 14.2 Function declaration
 14.3 Function results
 14.4 Parameter lists
  14.4.1 Value parameters
  14.4.2 Variable parameters
  14.4.3 Out parameters
  14.4.4 Constant parameters
  14.4.5 Open array parameters
  14.4.6 Array of const
  14.4.7 Untyped parameters
  14.4.8 Managed types and reference counts
 14.5 Function overloading
 14.6 Forward declared functions
 14.7 External functions
 14.8 Assembler functions
 14.9 Modifiers
  14.9.1 alias
  14.9.2 cdecl
  14.9.3 cppdecl
  14.9.4 export
  14.9.5 hardfloat
  14.9.6 inline
  14.9.7 interrupt
  14.9.8 iocheck
  14.9.9 local
  14.9.10 MS_ABI_Default
  14.9.11 MS_ABI_CDecl
  14.9.12 MWPascal
  14.9.13 noreturn
  14.9.14 nostackframe
  14.9.15 overload
  14.9.16 pascal
  14.9.17 public
  14.9.18 register
  14.9.19 safecall
  14.9.20 saveregisters
  14.9.21 softfloat
  14.9.22 stdcall
  14.9.23 SYSV_ABI_Default
  14.9.24 SYSV_ABI_CDecl
  14.9.25 VectorCall
  14.9.26 varargs
  14.9.27 winapi
 14.10 Unsupported Turbo Pascal modifiers
15 Operator overloading
 15.1 Introduction
 15.2 Operator declarations
 15.3 Assignment operators
 15.4 Arithmetic operators
 15.5 Comparison operator
 15.6 In operator
 15.7 Logical operators
 15.8 Inc/Dec operators
 15.9 The enumerator operator
16 Programs, units, blocks
 16.1 Programs
 16.2 Units
 16.3 Namespaces: Dotted Units
 16.4 Unit dependencies
 16.5 Blocks
 16.6 Scope
  16.6.1 Block scope
  16.6.2 Record scope
  16.6.3 Class scope
  16.6.4 Unit scope
 16.7 Libraries
17 Exceptions
 17.1 The raise statement
 17.2 The try...except statement
 17.3 The try...finally statement
 17.4 Exception handling nesting
 17.5 Exception classes
18 Using assembler
 18.1 Assembler statements
 18.2 Assembler procedures and functions