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

Sven Barth pascaldragon at googlemail.com
Thu Dec 12 07:13:53 CET 2019

Am 11.12.2019 um 23:40 schrieb Ryan Joseph via fpc-devel:
>> On Dec 11, 2019, at 4:16 PM, Michael Van Canneyt <michael at freepascal.org> 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.
Do you consider this as a variable "amount of arguments" as well?

=== code begin ===

function CalcSum(aArg: array of Integer): Integer;
   i: Integer;
   Result := 0;
   for i in aArg do
    Result := Result + i;

   a: array of Integer;
   Writeln(CalcSum([21, 54, 67, 89]));
   a := [94, 28, 85, 32];

=== code end ===

This uses the same mechanism, namely "open array" as "array of const" is 
in reality an "array of TVarRec" where the compiler automatically 
converts the incoming variables into a TVarRec.

In the Pascal world this is considered *one* argument. In contrast 
Writeln() supports a variable amount of arguments.


More information about the fpc-devel mailing list