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

Michael Van Canneyt michael at freepascal.org
Wed Dec 11 22:16:40 CET 2019



On Wed, 11 Dec 2019, Ryan Joseph via fpc-devel wrote:

>
>
>> On Dec 10, 2019, at 5:14 PM, Sven Barth via fpc-devel <fpc-devel at lists.freepascal.org> wrote:
>> 
>> From the view of the *caller* you are mostly right. Though the square brackets can't be left away, cause we're talking about an array parameter here. If it would be allowed for array of const then it would also need to be allowed for other open array parameters for consistency. But then it wouldn't be consistent with open array arguments in the middle. Each exception makes the language more complex.
>> 
>
> Yeah it's an array but it's also slightly annoying when the meaning is
> basically what we know as "varargs", i.e.  an unspecified amount of extra
> parameters.

No it is not varargs. See below.

> This common pattern in Format() is a good example of a last
> parameter array of const which doesn't really gain anything by adding the
> extra [] every time.  I smell another mode switch.  :)

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

"Array of const" is a notation for an open array construct : "array of vararg".

>
> Format('%dx%d',[100,100]);

As Sven already said: It is not varargs, since the array of const has extra
info when passed to the function. varargs does not pass any extra info.


So it is good to keep the 2 constructs clearly separated, and the [] makes a
a very clear distinction, as it indicates an (open) array, which it in fact
is.

This distinction should not be removed. Not even under a modeswitch.

Michael.


More information about the fpc-devel mailing list