Appendix F: Pascal Reserved Words and Operators
This appendix provides a complete reference of Pascal reserved words, operators with their precedence rules, compiler directives, and standard identifiers (predefined names that are not technically reserved). All entries reflect Free Pascal 3.2+ in {$mode objfpc} unless otherwise noted.
F.1 Reserved Words
Reserved words cannot be used as identifiers (variable names, type names, etc.) in Pascal. They are case-insensitive: begin, Begin, and BEGIN are all the same reserved word.
Core Reserved Words
| Word | Description |
|---|---|
absolute |
Declares a variable at a specific address or overlapping another variable |
and |
Boolean/bitwise AND operator |
array |
Array type declaration |
asm |
Inline assembly block |
begin |
Opens a compound statement block |
case |
Multi-way branch statement |
const |
Constant or constant-parameter declaration |
constructor |
Class constructor method |
destructor |
Class destructor method |
div |
Integer division operator |
do |
Follows for, while, with |
downto |
Descending for loop direction |
else |
Alternative branch of if or case |
end |
Closes a compound statement, record, class, or unit |
file |
File type declaration |
for |
Counted loop |
function |
Function declaration |
goto |
Unconditional jump (discouraged) |
if |
Conditional statement |
implementation |
Implementation section of a unit |
in |
Set membership test; also used in uses clause for unit paths and for..in |
inherited |
Calls parent class method |
inline |
Requests inline expansion of a routine |
interface |
Interface section of a unit; also interface type declaration |
label |
Declares a goto label |
mod |
Integer modulus operator |
nil |
Null pointer/object value |
not |
Boolean/bitwise NOT operator |
object |
Old-style object type (TP-compatible; use class for modern code) |
of |
Used with case, array, set, file, class of |
operator |
Operator overloading (ObjFPC mode) |
or |
Boolean/bitwise OR operator |
packed |
Requests no padding in composite types |
procedure |
Procedure declaration |
program |
Program heading |
record |
Record type declaration |
repeat |
Post-test loop (repeat...until) |
set |
Set type declaration |
shl |
Bitwise shift left |
shr |
Bitwise shift right |
string |
String type |
then |
Follows if condition |
to |
Ascending for loop direction |
type |
Type declaration section |
unit |
Unit heading |
until |
Terminates repeat loop |
uses |
Declares unit dependencies |
var |
Variable declaration section |
while |
Pre-test loop |
with |
Opens record/object scope |
xor |
Boolean/bitwise exclusive OR |
OOP and Advanced Reserved Words
| Word | Description |
|---|---|
as |
Safe typecast for class/interface types (Obj as TClass) |
class |
Class type declaration; also class function, class procedure, class operator |
dispose |
Frees memory allocated with New (for old-style objects/pointers) |
except |
Exception handler block in try...except |
exports |
Exports symbols from a library |
finalization |
Unit cleanup code (runs at program exit) |
finally |
Guaranteed-execution block in try...finally |
generic |
Generic type declaration (ObjFPC mode) |
initialization |
Unit startup code (runs at program load) |
is |
Runtime type check (Obj is TClass) |
library |
Shared library/DLL heading |
new |
Allocates memory for a pointer or old-style object |
on |
Exception type specifier in except block |
out |
Output parameter mode |
property |
Property declaration in a class |
raise |
Raises an exception |
resourcestring |
Declares translatable string constants |
self |
Reference to the current object instance |
specialize |
Generic type instantiation (ObjFPC mode) |
threadvar |
Thread-local variable |
try |
Begins protected block for exception handling |
F.2 Modifiers (Context-Sensitive Keywords)
These words have special meaning in certain contexts but can be used as identifiers elsewhere. Free Pascal treats them as modifiers rather than true reserved words.
| Modifier | Context |
|---|---|
abstract |
Virtual method with no implementation |
alias |
External symbol alias for a routine |
assembler |
Routine is written in assembly |
bitpacked |
Pack record/array at the bit level |
break |
Exit from a loop (also a standard procedure) |
cdecl |
C calling convention |
continue |
Skip to next loop iteration (also a standard procedure) |
cppdecl |
C++ calling convention |
cvar |
C-compatible variable declaration |
default |
Default value for a property |
deprecated |
Marks a symbol as deprecated |
dynamic |
Dynamically dispatched method (like virtual but uses index) |
enumerator |
Declares a for..in enumerator |
experimental |
Marks a symbol as experimental |
export |
Calling convention for exported functions |
external |
Links to an external (C/DLL) function |
far |
Far call model (16-bit legacy) |
forward |
Forward-declares a routine |
implements |
Property implements an interface |
index |
Property index or external function ordinal |
interrupt |
Interrupt handler routine |
iochecks |
I/O checking modifier |
local |
Symbol not exported from the unit |
message |
Message handler method |
name |
External function name |
near |
Near call model (16-bit legacy) |
nodefault |
Property has no default value |
noreturn |
Routine never returns (e.g., Halt) |
nostackframe |
Omit stack frame setup |
oldfpccall |
Old FPC calling convention |
otherwise |
Alias for else in case (ISO Pascal) |
overload |
Allows multiple routines with the same name but different parameters |
override |
Replaces a virtual method in a descendant class |
pascal |
Pascal calling convention |
platform |
Marks a symbol as platform-specific |
private |
Private visibility section |
protected |
Protected visibility section |
public |
Public visibility section |
published |
Published visibility section (with RTTI) |
read |
Property read accessor |
register |
Register calling convention (default) |
reintroduce |
Hides a parent virtual method intentionally |
result |
Function return value variable |
safecall |
Safecall calling convention (COM exception handling) |
saveregisters |
Caller saves registers |
softfloat |
Software floating-point calling convention |
static |
Class method that does not receive Self |
stdcall |
Standard Windows calling convention |
stored |
Whether a property value should be streamed |
strict |
Prefixes private or protected for truly strict visibility |
unaligned |
Data may be unaligned |
unimplemented |
Marks a symbol as unimplemented |
varargs |
C-style variable argument list |
virtual |
Virtual method dispatch |
winapi |
Platform-specific API calling convention |
write |
Property write accessor |
F.3 Operators and Precedence
Complete Operator Table
| Operator | Operation | Category |
|---|---|---|
not |
Boolean NOT / Bitwise NOT | Unary |
@ |
Address-of | Unary |
- (unary) |
Negation | Unary |
+ (unary) |
Identity (no-op) | Unary |
^ |
Pointer dereference | Unary (postfix) |
* |
Multiplication / Set intersection | Multiplicative |
/ |
Real division | Multiplicative |
div |
Integer division | Multiplicative |
mod |
Integer remainder | Multiplicative |
and |
Boolean AND / Bitwise AND | Multiplicative |
shl |
Shift left | Multiplicative |
shr |
Shift right | Multiplicative |
as |
Safe typecast | Multiplicative |
** |
Exponentiation (when operator overloaded) | Multiplicative |
+ |
Addition / String concatenation / Set union | Additive |
- |
Subtraction / Set difference | Additive |
or |
Boolean OR / Bitwise OR | Additive |
xor |
Boolean XOR / Bitwise XOR | Additive |
= |
Equal to | Comparison |
<> |
Not equal to | Comparison |
< |
Less than / Proper subset | Comparison |
> |
Greater than / Proper superset | Comparison |
<= |
Less than or equal / Subset | Comparison |
>= |
Greater than or equal / Superset | Comparison |
in |
Set membership | Comparison |
is |
Runtime type check | Comparison |
Precedence Table (Highest to Lowest)
| Level | Category | Operators |
|---|---|---|
| 1 | Unary | not, @, unary +, unary - |
| 2 | Multiplicative | *, /, div, mod, and, shl, shr, as, ** |
| 3 | Additive | +, -, or, xor |
| 4 | Comparison | =, <>, <, >, <=, >=, in, is |
Operators at the same level are evaluated left to right. Use parentheses to override precedence or to improve readability.
Precedence Pitfall
Because and and or have higher precedence than comparison operators, boolean expressions require parentheses around comparisons:
{ WRONG — parsed as: if (A > 0) and (B < (10 then)) — syntax error }
if A > 0 and B < 10 then ...
{ CORRECT }
if (A > 0) and (B < 10) then ...
This is different from C-family languages where && has lower precedence than < and >.
F.4 Compiler Directives Quick Reference
Compiler directives are enclosed in {$ }` or `(*$ *). They are not reserved words but are processed by the compiler.
Switch Directives (On/Off)
| Directive | Default | Purpose |
|---|---|---|
{$A+}/{$A-} |
{$A+} |
Data alignment on/off |
{$B+}/{$B-} |
{$B-} |
Full boolean evaluation / short-circuit |
{$C+}/{$C-} |
{$C+} |
Assertions on/off |
{$D+}/{$D-} |
{$D+} |
Debug information on/off |
{$H+}/{$H-} |
Mode-dependent | AnsiString / ShortString default |
{$I+}/{$I-} |
{$I+} |
I/O checking on/off |
{$J+}/{$J-} |
{$J-} |
Typed constants writable / read-only |
{$M+}/{$M-} |
{$M-} |
RTTI generation on/off |
{$Q+}/{$Q-} |
{$Q-} |
Overflow checking on/off |
{$R+}/{$R-} |
{$R-} |
Range checking on/off |
{$S+}/{$S-} |
{$S+} |
Stack checking on/off |
{$T+}/{$T-} |
{$T-} |
Typed @ operator on/off |
{$V+}/{$V-} |
{$V+} |
Strict string var-checking on/off |
{$W+}/{$W-} |
{$W-} |
Windows stack frames on/off |
{$X+}/{$X-} |
{$X+} |
Extended syntax on/off (discard function results) |
Conditional Directives
| Directive | Purpose |
|---|---|
{$DEFINE name} |
Define a symbol |
{$UNDEF name} |
Undefine a symbol |
{$IFDEF name} |
Compile if symbol is defined |
{$IFNDEF name} |
Compile if symbol is not defined |
{$IF expr} |
Compile if expression is true |
{$ELSEIF expr} |
Alternative branch with condition |
{$ELSE} |
Alternative branch |
{$ENDIF}` / `{$IFEND} |
End conditional block |
Other Directives
| Directive | Purpose |
|---|---|
{$I filename} |
Include a file |
{$L filename} |
Link an object file |
{$R filename} |
Include a resource file |
{$MODE name} |
Set compiler mode (objfpc, delphi, tp, etc.) |
{$MODESWITCH name} |
Enable/disable a specific language feature |
{$CODEPAGE name} |
Set source file code page |
{$INLINE ON/OFF} |
Enable/disable inline expansion |
{$OPTIMIZATION ON/OFF} |
Enable/disable optimizations |
{$PUSH} |
Save current compiler switch state |
{$POP} |
Restore saved compiler switch state |
{$WARN id ON/OFF/ERROR} |
Control specific warning |
{$INTERFACES COM/CORBA} |
Set interface style |
{$CALLING conv} |
Set default calling convention |
{$PACKENUM n} |
Set enum size (1, 2, or 4 bytes) |
{$PACKRECORDS n} |
Set record alignment (1, 2, 4, 8, 16, C, or DEFAULT) |
{$ALIGN n}` | Alias for `{$PACKRECORDS} |
|
{$MACRO ON/OFF} |
Enable/disable macro support |
{$SCOPEDENUMS ON/OFF} |
Require enum type prefix |
F.5 Standard Identifiers
Standard identifiers are predefined by the compiler but are not reserved words. You can redefine them (though doing so is strongly discouraged as it makes code confusing and can cause hard-to-find bugs).
Standard Types
| Identifier | Description |
|---|---|
Integer |
Platform-sized signed integer (typically 32-bit) |
Cardinal |
Platform-sized unsigned integer |
LongInt |
32-bit signed integer |
LongWord |
32-bit unsigned integer |
SmallInt |
16-bit signed integer |
Word |
16-bit unsigned integer |
ShortInt |
8-bit signed integer |
Byte |
8-bit unsigned integer |
Int64 |
64-bit signed integer |
QWord |
64-bit unsigned integer |
Boolean |
True / False |
ByteBool, WordBool, LongBool |
Boolean types of various sizes |
Char |
8-bit character (AnsiChar) |
WideChar |
16-bit character |
Real |
Floating-point (alias for Double) |
Single |
32-bit float |
Double |
64-bit float |
Extended |
80-bit float (platform-dependent) |
Currency |
Fixed-point 64-bit (4 decimal places) |
Comp |
64-bit integer stored as float (legacy) |
AnsiString |
Reference-counted string |
UnicodeString |
UTF-16 reference-counted string |
WideString |
COM-compatible wide string |
ShortString |
Stack-allocated 255-char string |
PChar |
Pointer to null-terminated Char array |
Pointer |
Untyped pointer |
Text |
Alias for TextFile |
TObject |
Base class of all classes |
IInterface / IUnknown |
Base interface types |
TClass |
Metaclass of TObject |
HRESULT |
COM result type |
Standard Constants
| Identifier | Value |
|---|---|
True |
Boolean true |
False |
Boolean false |
nil |
Null pointer (also a reserved word) |
MaxInt |
Maximum Integer value (2147483647) |
MaxLongInt |
Maximum LongInt value |
Pi |
3.1415926535897932385 |
LineEnding |
Platform-specific line ending (#13#10 on Windows, #10 on Unix) |
DirectorySeparator |
\ on Windows, / on Unix |
PathSeparator |
; on Windows, : on Unix |
Standard Procedures and Functions
| Identifier | Description |
|---|---|
Write, WriteLn |
Output to text file or console |
Read, ReadLn |
Input from text file or console |
Inc, Dec |
Increment / decrement |
Ord, Chr |
Ordinal value / character from ordinal |
Succ, Pred |
Next / previous ordinal value |
Low, High |
Lowest / highest value of type or array |
Length |
Length of string or array |
SetLength |
Resize dynamic array or string |
SizeOf |
Size of type or variable in bytes |
Assigned |
Test if pointer/object/procedural variable is non-nil |
New, Dispose |
Allocate / free typed pointer |
GetMem, FreeMem, ReallocMem |
Allocate / free / resize untyped memory |
FillChar, Move |
Fill / copy memory blocks |
Copy, Delete, Insert, Concat, Pos |
String operations |
Str, Val |
Number-to-string / string-to-number conversion |
Halt |
Terminate program |
Exit |
Leave current routine |
Break, Continue |
Loop control |
Assert |
Debug assertion |
Include, Exclude |
Add / remove element from set |
TypeInfo |
Return RTTI pointer for a type |
Default |
Return default value for a type (FPC 3.2+) |
AssignFile, Reset, Rewrite, Append, CloseFile |
File operations |
BlockRead, BlockWrite |
Binary file block I/O |
Eof, Eoln, SeekEof, SeekEoln |
File position tests |
Seek, FilePos, FileSize |
File positioning |
Random, Randomize |
Random number generation |
Abs, Sqr, Sqrt, Round, Trunc, Frac, Int |
Math functions |
Sin, Cos, ArcTan, Ln, Exp |
Transcendental functions |
Odd |
Returns True if argument is odd |
Swap, Lo, Hi |
Byte/word manipulation |
UpCase |
Convert character to uppercase (ASCII only) |
Concat |
Concatenate strings |
StringOfChar |
Create string of repeated character |
ParamCount, ParamStr |
Command-line arguments |
This appendix serves as a quick lookup when you need to check whether a word is reserved, verify operator precedence, or find the right compiler directive. Keep it handy as you write Pascal code.