Is it somehow possible to assign an static array to an dynamic array, without copying the whole values? I just want to use the address of the static array to get it's value from some other routines. For performance reasons.

Is it somehow possible to assign an static array to an dynamic array, without copying the whole values? I just want to use the address of the static array to get it's value from some other routines. For performance reasons.

fStringArray: array of string;
...
const STATIC_ARRAY: array[0..1] of string = ('s1', 's2');
....
procedure MyClass.SetArray(aStringArray: array of string);
begin
  fStringArray := aStringArray;  //Error: Incomatiple types
end;
...
SetArray(STATIC_ARRAY);

Comments

  1. Stefan Glienke  I'd be astounded if anybody could disagree with that. That change, and the handful of analagous ones for different element types would make a big difference.

    ReplyDelete
  2. David Heffernan Oh, I remember an argument about that some versions ago but I cannot remember the arguments that were brought up against this because I don't see any problems tbh. Unfortunately it seems that QC is down right now so I cannot look up the issues that were entered for this.

    ReplyDelete
  3. Stefan Glienke a more final solution would just be to make all "array of Whatever" inter-operable: if a type is written in the same way, it should be the same type.

    Beyond the dynamic array types mismatch, the distinction between open arrays and dynamic arrays is ofttimes annoying f.i. (as illustrated by the starting point of this thread).

    ReplyDelete

Post a Comment