General

Types

Numbers and keywords

Example I (for-to)
for i:=1 to 100 do doSomething(i);
for i:=1to 100do doSomething(i);
Example II (repeat-until)
i:=0;repeat doSomething(i);i+=1;until i=100;
i:=0;repeat doSomething(i);i+=1until i=100;
Example III (end)
begin i:=0;repeat i+=1;doSomething(i)until i=100;end.
begin i:=0;repeat i+=1;doSomething(i)until i=100end.
{❌ ERROR, parsed as 100e and expecting the exponent}
begin i:=0;repeat i+=1;doSomething(i)until i=1e2end.
{✅ NO ERROR}

HEX and OCT integers

Example I (hex superiority)
begin doSomething(x);x:=x div 10;end;
begin doSomething(x);x:=x div$a;end;
Example II (oct superiority)
begin doSomething(x);x:=x div 500;end;
begin doSomething(x);x:=x div$1f4;end;
begin doSomething(x);x:=x div$1f4end;
{❌ ERROR, FPC is trying to parse "$1f4e" as a hex integer}
begin doSomething(x);x:=x div&764;end;
begin doSomething(x);x:=x div&764end;
{✅ NO ERROR, oct values don't have 'e' in the range of digits and can't be represented in scientific notation}

Loops

Example I (one operation)
for i:=1to 100do doSomething(i);
i:=0;repeat i+=1;doSomething(i)until i=100;
Example II (two operations)
for i:=1to 100do begin doSomething(i);doSomethingElse(i)end;
i:=0;repeat i+=1;doSomething(i);doSomethingElse(i)until i=100;
Example III (two operations with a variable implicitly set to 0)
var i:word;{...}for i:=1to 100do begin doSomething(i);doSomethingElse(i)end;
var i:word;{...}repeat i+=1;doSomething(i);doSomethingElse(i)until i=100;

Functions and procedures

Example I (no args)
begin writeln()end.
begin writeln;end.
Example II (func name)
function f(x:word):word;
var i:word;
begin
  for i:=1to x do doSomething(i);
  f:=x*x;
end;
function f(x:word):word;
begin
  for f:=1to x do doSomething(f);
  f:=x*x;
end;

Arguments number

Example
var i:word;begin for i:=1 to 100 do doSomething(i);end.
begin for argc:=1 to 100 do doSomething(argc);end.

CTRL-format for characters

Example (^` vs ' ')
{$H+}
uses sysutils;begin writeln('code golf'.split(' ')[1]);end.
{$H+}
uses sysutils;begin writeln('code golf'.split(^`)[1]);end.
Most useful replacements
^@ --> '\0'
^i --> '\t'
^j --> '\n'
^m --> '\r'

^` --> ' '
^< --> '|'
^> --> '~'

^a..^z --> char(1)..char(26)
^0..^9 --> 'p'..'y'

Variant

Example (FizzBuzz mock)
{n bytes}
var i:word;s:string;
begin
 for i:=1 to 100 do begin
  s:=getFizzBuzzString(i);
  if s=''then write(i);
  writeln(s);
 end;
end.
{n-3 bytes}
var i:word;s:variant;
begin
 for i:=1 to 100 do begin
  s:=getFizzBuzzString(i);
  if s=''then s:=i;
  writeln(s);
 end;
end.

String to Number parsing

Example
var x:int32;s:string='69419';begin val(s,x);writeln(x+1)end.
uses sysutils;var s:string='69418';begin writeln(strtoint(s)+2)end.
uses{$H+}sysutils;var s:string='69417';begin writeln(s.toint64+3)end.
uses strutils;var s:string='69416';begin writeln(numb2dec(s,10)+4)end.
var v:variant;x:int32;s:string='69415';begin v:=s;x:=v;writeln(x+5)end.
uses sysutils;var x:int32;s:string='69414';begin sscanf(s,'%d',[@x]);writeln(x+6)end.

Packer

2:1

uses sysutils;
var f:text;c:wchar;
begin
assign(f,^0);rewrite(f);
for c in utf8decode('PACKED_CODE_UTF16')do write(f,chr(ord(c)and$FF)+chr(ord(c)>>8));
close(f);
executeprocess('/usr/bin/fpc','p -v1');
executeprocess(^0,'')
end.