[fpc-devel] open array calling [[was: Re: C-block reference syntax (blocker for 3.2)]]

Sven Barth pascaldragon at googlemail.com
Thu Dec 12 20:04:10 CET 2019


Am 12.12.2019 um 17:23 schrieb Michael Van Canneyt:
>
>
> On Thu, 12 Dec 2019, Martin Frb wrote:
>
>> On 12/12/2019 17:14, Michael Van Canneyt wrote:
>>> On Thu, 12 Dec 2019, Sven Barth via fpc-devel wrote:
>>>> For array of const it is not allowed, but any other open array 
>>>> parameter
>>>> allows it.
>>>
>>> Really, are you sure ? Since when is this allowed ?
>>
>> It works with a variable in the param list, but not with a constant.
>>
>> program Project1;
>> procedure Foo(a: array of integer);
>> begin  end;
>>
>> var a: integer;
>> begin
>>   foo(a);
>> //  foo(1);  // fails
>> end.
>>
>>
>> And then it also works for array of const
>>
>> program Project1;
>> procedure Foo(a: array of const);
>> begin  end;
>>
>> var a: TVarRec;
>> begin
>>   foo(a);
>> end.
>
> Great :(
>
> Hm. I modified the delphi program to check. It also works with a 
> variable...
>
> What kind of braindead "feature" is this ? :(
I don't know why Borland decided to add this back then, but the 
implementation itself is rather easy as an open array is simply a 
pointer to the first element and a count. Thus for variables the 
compiler simply takes the pointer to the variable and passes a constant 
1 as count.

Regards,
Sven


More information about the fpc-devel mailing list