On Thu, 12 Dec 2019, Martin Frb wrote:

It does gain something: it tells you it is NOT a varargs, but an array of
const, which is a different beast altogether.

But it's a syntax equivalent for "a variable amount of arguments", i.e. varargs. ;) I guess others don't see it this way however.

Somecall(fmt : String; args : Array of Const; anOptionalArg : TType = SomeDefault);

That still would not break, but it actually is the base for something that would break.

The point was to demonstrate that array of const is 1 argument. It is not equal to a variable number of arguments.

It was already mentioned, that the [] can be dropped if the array has *exactly one* element.

Not sure what you mean here, but even if there is only 1 argument, today the [] 
cannot be dropped:

home:~> cat tf.pp
program tf;

uses sysutils;

begin
  writeln(Format('%s','huh?'));
end.
home:~> fpc tf.pp
tf.pp(6,29) Error: Incompatible type for arg no. 2: Got "Constant String", expected 
"Array Of Const"
tf.pp(8) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/local/bin/ppcx64 returned an error exitcode


Michael.
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to