Chapter 3
Types

All variables have a type. Free Pascal supports the same basic types as Turbo Pascal, with some extra types from Delphi as well as some of its own.

The programmer can declare his own types, which is in essence defining an identifier that can be used to denote this custom type when declaring variables further in the source code. Declaring a type happens in a Type block (section 16.5, page 945), which is a collection of type declarations, separated by semicolons:

_________________________________________________________________________________________________________
Type declaration

--type-declaration- identifier-=  -type -|--------------;---------------
                                  -hint- directives-
___________________________________________________________________

There are eight major kinds of types:

_________________________________________________________________________________________________________
Types

--    ----         ---------------------------------------------
  type   --simple- type---|
        -stsrturictnugr- tedy-ptyepe -|
        --pointer- type--|
        -procedural- type-|
        |-generic-type---|
        |specialized- type-|
        ---type-alias-----
___________________________________________________________________

Each of these cases will be examined separately.

A syntax diagram has no notion of the type of an identifier or expression. However, sometimes it is useful (or necessary) to know the type of an identifier. To make the syntax diagrams more clear, the type of an identifier has been added as a prefix to the name. The following is a list of such typed identifiers:

_________________________________________________________________________________________________________
Typed identifiers

--object- type- identifier-fully- qualified-identifier--------------------------

--class- type-identifier-fully- qualified-identifier----------------------------

--field-identifier-fully- qualified-identifier--------------------------------

--              -                  ------------------------------
  interface- identifier fully- qualified-identifier

--                  -                  -------------------------
  interface- type-identifier fully- qualified-identifier

--             -                  ------------------------------
  method- identifier  fully- qualified- identifier

--procedure- identifier-fully- qualified-identifier---------------------------

--protocol- type- identifier fully-qualified- identifier--------------------------

--qualified-method- identifier fully- qualified-identifier------------------------

--type-identifier-fully- qualified-identifier--------------------------------

--function-identifier-fully-qualified-identifier -----------------------------

--unit-identifier -fully-qualified-identifier --------------------------------

--variable- identifier- fully- qualified- identifier------------------------------

--enumerated- type- identifier-fully- qualified-identifier-----------------------

--float- type-identifier-fully- qualified-identifier---------------------------
___________________________________________________________________

from a perspective of language syntax, they can all be replaced by fully-qualified-identifier

 3.1 Base types
  3.1.1 Ordinal types
  3.1.2 Floating-point 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