Below are a few overloaded features. Try to guess which function will be called.
program Project2;
{$APPTYPE CONSOLE}
uses
Types, SysUtils;
procedure Some(const Buf); overload;
begin
Writeln('const-typeless')
end;
procedure Some(Buf :array of Byte); overload;
begin
Writeln('Byte open array');
end;
procedure Some(Buf :TArray<Byte>); overload;
begin
Writeln('TBytes AKA byte generic array');
end;
var p: pointer;
begin
try
{ TODO -oUser -cConsole Main : Insert code here }
WriteLn ('Calling overloaded procedure with Pointer parameter:');
Write(' * nil: '); p := nil; Some(p);
Write(' * garbage: '); p := Pointer(1); Some(p);
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
ReadLn;
end.
In fact, the 1st number is called and issues AV to 2ndcall. Given that the old VCL pattern uses Pointer and Integer interchangeably (for example, TList and TStrings.Objects and TWinControl.Tag), which can cause unexpected AV requests on fairly regular code.
{$ T +} , Delphi , ^ Byte .
p: PInteger; . / -, generic-array. - , , " " . , - .
/ , , , PInteger?
PS. QC 109019