Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2007-01

function Copy is inconsistent with Delphi

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Alexander Todorov

Hello,
i am converting a big Delphi project a part of uses a lexical parser. It is dependent on the Copy function which in Delphi is declared:

function Copy(S; Index, Count: Integer): string;

and in FPC it is:

function Copy(const s: string; FromPosition, ToPosition : integer): String;

Why there are different declarations? I see that the FPC variant is used in a lot of places and it is not likely that it will be changed to be compatible with Delphi.

Thanks to all.

Michael Van Canneyt
to Alexander Todorov
Alexander Todorov wrote 14 lines
Hello, i am converting a big Delphi project a part of uses a lexical parser. It is dependent on the Copy function which in Delphi is declared: function Copy(S; Index, Count: Integer): string; and in FPC it is: function Copy(const s: string; FromPosition, ToPosition : integer): String; Why there are different declarations? I see that the FPC variant is used in a lot of places and it is not likely that it will be changed to be compatible with Delphi.

As far as I know, The Delphi variant is used also to copy dynamic arrays, possibly also variant arrays. The above function is a dummy declaration, as found in the documentation - because in reality it is handled by internal system functions (you can search for _copy, _copyvar _objCopy etc. in the system unit of delphi).

However, for strings, the behaviour should be the same.

For dynamic arrays, I don't think FPC has a similar function.

Michael.