-
ONiX
- Site Admin
- Posts: 165
- Joined: Tue Nov 18, 2025 1:27 am
Post
by ONiX »
What made the cut?
overload
Code: Select all
procedure WriteLn(x: Integer); overload;
procedure WriteLn(x: String); overload;
procedure WriteLn(x: Real); overload;
WriteLn(42); { Calls Integer version }
WriteLn('hello'); { Calls String version }
WriteLn(3.14); { Calls Real version }
dynamic arrays
Code: Select all
var
arr: array of Integer; { No fixed size }
begin
SetLength(arr, 10);
arr[0] := 5;
SetLength(arr, 20); { Grow }
arr[15] := 15;
SetLength(arr, 5); { Shrink }
end;
type forward declarations
Code: Select all
type
PNode = ^Node; { Forward reference }
Node = record
value: Integer;
next: PNode; { Can now use PNode }
end;
-
ONiX
- Site Admin
- Posts: 165
- Joined: Tue Nov 18, 2025 1:27 am
Post
by ONiX »
more
nested closures
Code: Select all
procedure Outer;
var
x: Integer;
begin
x := 10;
procedure Inner;
begin
WriteLn(x); { Access outer scope }
end;
Inner();
end;
procedure references
Code: Select all
type
TCallback = procedure(x: Integer);
var
callback: TCallback;
begin
callback := @SomeProcedure;
callback(42); { Call through reference }
end;
operator overloading
Code: Select all
type
TVector = record x, y: Real; end;
operator +(a, b: TVector): TVector;
begin
Result.x := a.x + b.x;
Result.y := a.y + b.y;
end;
v1 := v2 + v3; { Natural syntax! }