[fpc-pascal] Passing a string to open array of string
Martin
lazarus at mfriebe.de
Sat Mar 31 20:43:26 CEST 2012
On 31/03/2012 19:34, Jonas Maebe wrote:
> On 31 Mar 2012, at 12:07, cobines wrote:
>
>> The following program compiles and correctly prints 'something'. Is it
>> something supported or a bug?
> It is supported. Even Turbo Pascal already supported passing a single element as an open array parameter.
>
Interesting, yet the following overloaded functions, compile too. In
other cases, if more than one match for a call exists, it gives an error.
special optimization?
program Project1;
{$mode objfpc}{$H+}
procedure Proc(const s: array of string); overload;
begin
WriteLn(s[0]);
end;
procedure Proc(const s: string); overload;
begin
WriteLn(s);
end;
var
s: string = 'something';
begin
Proc(s);
readln
end.
More information about the fpc-pascal
mailing list