[fpc-devel] C-block reference syntax (blocker for 3.2)

Michael Van Canneyt michael at freepascal.org
Thu Dec 12 15:34:15 CET 2019



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.


More information about the fpc-devel mailing list