Lexical Elements: Identifiers, Comments & Case Insensitivity
FPC allows nested comments of the same kind in fpc/objfpc modes; Delphi does not — avoid relying on it.
4.1 Identifiers
Start with a letter or underscore, followed by letters, digits, or underscores: Total, _temp, Item2.
Case-insensitive: Total, total, and TOTAL are the same identifier.
Significant length: effectively unlimited in FPC/Delphi (FPC: 127 characters; Delphi: 255).
Reserved words (begin, end, type, ...) cannot be used as identifiers — unless escaped with & in Delphi and FPC: &Type, &Begin.
Unit-qualified names: SysUtils.IntToStr, System.SysUtils.IntToStr (Delphi unit scopes).
4.2 Comments
FPC allows nested comments of the same kind in fpc/objfpc modes; Delphi does not — avoid relying on it.
{ Curly-brace comment — can span lines }
(* Parenthesis-star comment — also multi-line *)
// Line comment (Delphi and FPC; not in ISO Pascal)
{ Comments of different kinds can nest: (* inner *) }
{$R+} // NOT a comment: a brace followed by $ is a compiler directive4.3 Literals
42, -7, $FF (hex), &17 (octal, FPC), %1010 (binary), 1_000_000 (digit separators: Delphi 11+, FPC trunk) 3.14, 1.5e-3, 2E10
'A', #65 (character code), #13#10 (CR LF), ^M (control char, legacy)
'Hello', 'It''s' (doubled quote), 'Line 1' + sLineBreak + 'Line 2'
Delphi 12+: text between triple quotes ''' on separate lines True, False [1, 3, 5..9], ['a'..'z']
4.4 Naming conventions (Delphi/FPC community)
T prefix, PascalCase TCustomer, TPoint3D often A prefix AName, AOwner Local variables, routines TotalCount, CalculateTax PascalCase or UPPER_CASE MaxUsers, DEFAULT_PORT clRed, fsBold, ssShift