free_pascal_reference_guide.pdf

(631 KB) Pobierz
42575704 UNPDF
FreePascal:
Referenceguide.
ReferenceguideforFreePascal,version2.0.4
Documentversion2.0
August2006
MichaëlVanCanneyt
 
Contents
1PascalTokens 9
1.1Symbols ......................................... 9
1.2Comments ........................................ 9
1.3Reservedwords ..................................... 10
1.3.1TurboPascalreservedwords .......................... 10
1.3.2Delphireservedwords ............................. 11
1.3.3FreePascalreservedwords ........................... 11
1.3.4Modifiers .................................... 11
1.4Identifiers ........................................ 11
1.5Numbers ......................................... 12
1.6Labels .......................................... 13
1.7Characterstrings .................................... 13
2Constants 14
2.1Ordinaryconstants ................................... 14
2.2Typedconstants ..................................... 15
2.3Resourcestrings ..................................... 16
3Types 17
3.1Basetypes ........................................ 17
3.1.1Ordinaltypes .................................. 18
Integers ..................................... 18
Booleantypes .................................. 19
Enumerationtypes ............................... 20
Subrangetypes ................................. 21
3.1.2Realtypes .................................... 21
3.2Charactertypes ..................................... 22
3.2.1Char ....................................... 22
3.2.2Strings ..................................... 22
3.2.3Shortstrings .................................. 23
3.2.4Ansistrings ................................... 23
1
CONTENTS
3.2.5WideStrings ................................... 24
3.2.6Constantstrings ................................. 25
3.2.7PChar-Nullterminatedstrings ........................ 25
3.3StructuredTypes .................................... 26
3.3.1Arrays ...................................... 27
Staticarrays ................................... 27
Dynamicarrays ................................. 28
3.3.2Recordtypes .................................. 30
3.3.3Settypes .................................... 33
3.3.4Filetypes .................................... 34
3.4Pointers ......................................... 35
3.5Forwardtypedeclarations ................................ 36
3.6Proceduraltypes ..................................... 37
3.7Varianttypes ...................................... 38
3.7.1Definition .................................... 38
3.7.2Variantsinassignmentsandexpressions .................... 40
3.7.3Variantsandinterfaces ............................. 40
4Variables 42
4.1Definition ........................................ 42
4.2Declaration ....................................... 42
4.3Scope .......................................... 44
4.4ThreadVariables .................................... 44
4.5Properties ........................................ 44
5Objects 48
5.1Declaration ....................................... 48
5.2Fields .......................................... 49
5.3Constructorsanddestructors .............................. 50
5.4Methods ......................................... 51
5.5Methodinvocation ................................... 51
Staticmethods ................................. 52
Virtualmethods ................................. 52
Abstractmethods ................................ 53
5.6Visibility ........................................ 54
6Classes 55
6.1Classdefinitions ..................................... 55
6.2Classinstantiation .................................... 57
6.3Methods ......................................... 57
6.3.1 invocation .................................... 57
2
CONTENTS
6.3.2Virtualmethods ................................. 57
6.3.3Classmethods ................................. 58
6.3.4Messagemethods ................................ 59
6.4Properties ........................................ 60
7Interfaces 64
7.1Definition ........................................ 64
7.2Interfaceidentification:AGUID ............................ 65
7.3InterfacesandCOM ................................... 66
7.4CORBAandotherInterfaces .............................. 67
8Expressions 68
8.1Expressionsyntax .................................... 69
8.2Functioncalls ...................................... 70
8.3Setconstructors ..................................... 71
8.4Valuetypecasts ..................................... 72
8.5The@operator ..................................... 73
8.6Operators ........................................ 73
8.6.1Arithmeticoperators .............................. 73
8.6.2Logicaloperators ................................ 74
8.6.3Booleanoperators ............................... 75
8.6.4Stringoperators ................................. 75
8.6.5Setoperators .................................. 75
8.6.6Relationaloperators .............................. 75
9Statements 77
9.1Simplestatements .................................... 77
9.1.1Assignments .................................. 77
9.1.2Procedurestatements .............................. 78
9.1.3Gotostatements ................................. 79
9.2Structuredstatements .................................. 79
9.2.1Compoundstatements ............................. 80
9.2.2The Case statement .............................. 80
9.2.3The If..then..else statement ...................... 81
9.2.4The For..to/downto..do statement ................... 82
9.2.5The Repeat..until statement ....................... 83
9.2.6The While..do statement .......................... 84
9.2.7The With statement .............................. 84
9.2.8ExceptionStatements .............................. 86
9.3Assemblerstatements .................................. 86
3
CONTENTS
10Usingfunctionsandprocedures 88
10.1Proceduredeclaration .................................. 88
10.2Functiondeclaration .................................. 89
10.3Parameterlists ...................................... 89
10.3.1Valueparameters ................................ 90
10.3.2Variableparameters ............................... 90
10.3.3Outparameters ................................. 91
10.3.4Constantparameters .............................. 91
10.3.5Openarrayparameters ............................. 92
10.3.6Arrayofconst ................................. 92
10.4Functionoverloading .................................. 95
10.5Forwarddefinedfunctions ............................... 95
10.6Externalfunctions .................................... 96
10.7Assemblerfunctions .................................. 97
10.8Modifiers ........................................ 97
10.8.1alias ....................................... 98
10.8.2cdecl ...................................... 99
10.8.3export ...................................... 99
10.8.4inline ...................................... 99
10.8.5interrupt .....................................100
10.8.6nostackframe ..................................100
10.8.7pascal ......................................100
10.8.8public ......................................100
10.8.9register .....................................100
10.8.10safecall .....................................101
10.8.11softfloat .....................................101
10.8.12stdcall ......................................101
10.8.13varargs .....................................101
10.9UnsupportedTurboPascalmodifiers ..........................101
11Operatoroverloading 102
11.1Introduction .......................................102
11.2Operatordeclarations ..................................102
11.3Assignmentoperators ..................................103
11.4Arithmeticoperators ..................................105
11.5Comparisionoperator ..................................106
12Programs,units,blocks 108
12.1Programs ........................................108
12.2Units ...........................................109
12.3Blocks ..........................................110
4
Zgłoś jeśli naruszono regulamin