Maybe this:
Thanks, that is a very good thought. I am afraid I cannot use it, as the real world is much more complicated than the example I showed (I have more parameters after with no default value), but will see if I can do something with it.
What really makes me wonder here is the fact that you can use a function with an array of const, thus pass whatever you want to a single function and determine the type within once the code lands there.
a) I did not think of it
b) in my real world situation one of the two cases is an array of strings and the other is an array of records and if I know well records cannot be passed as untyped array of const parameter.
However now I found something not thought before, and almost works:
program simple;
uses
SysUtils;
type
integers = array of integer;
strings = array of string;
procedure a(const x: integers);
begin
writeln('In integers');
end;
procedure a(const x: array of string);
begin
Writeln('In strings');
end;
var
v1: strings;
begin
a([12,23]); // calls the integers - CORRECT
a(['a','b']); // calls the strings - CORRECT
v1 := [];
a(v1); // calls the strings - CORRECT
a([]); // calls the strings - HERE IT DECIDES FOR THE "array of..." VERSION
a(strings([])); // calls the integers - ERROR, THE TYPECAST DOES NOT WORK LIKE THIS
Sleep(500);
end.
As you see, I changed one of the declarations to a pre-defined type (instead of array of integer introduced integers). Then it almost works as intended.
The empty array calls the string version or to be more precise that one with the declaration like "array of something". The last one with the typecast works incorrectly, as it calls the integers (pre-defined) version, although the typecast would be the string version.
If I change the two declarations (to "array of integer" and "strings") then again, the first three will call what it should (obvious choices) the fourth calls the one with the "array of something" version (in this case the integer) and the last one calls the string version, but not because the typecast is strings([]), but because it calls the pre-defined type. Even if I use integers([]) it will call the strings version.