12.1 Programs

A pascal program consists of the program header, followed possibly by a 'uses' clause, and a block.

_________________________________________________________________________________________________________ Programs
-- --       -            -  --------------     - ------------------
     program  program header  ;  -         -|block  .
                               uses clause

-- --program header- program -identi  er-|------------------------------
                                    -( -program parameters- )--

-- --program parameters- identi  er list----------------------------------

-- --         -    ---       --- -----------------------------------
     uses clause  uses  6identi,- er| ;
___________________________________________________________________

The program header is provided for backwards compatibility, and is ignored by the compiler. The uses clause serves to identify all units that are needed by the program. The system unit doesn't have to be in this list, since it is always loaded by the compiler. The order in which the units appear is signicant, it determines in which order they are initialized. Units are initialized in the same order as they appear in the uses clause. Identiers are searched in the opposite order, i.e. when the compiler searches for an identier, then it looks rst in the last unit in the uses clause, then the last but one, and so on. This is important in case two units declare dierent types with the same identier. When the compiler looks for unit les, it adds the extension .ppu (.ppw for Win32 platforms) to the name of the unit. On linux and in operating systems where lenames are case sensitive, when looking for a unit, the unit name is rst looked for in the original case, and when not found, converted to all lowercase and searched for.

If a unit name is longer than 8 characters, the compiler will rst look for a unit name with this length, and then it will truncate the name to 8 characters and look for it again. For compatibility reasons, this is also true on platforms that suport long le names.