Sign in Join

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

Mailing lists / fpc-pascal / 2018-05

Dynamic Array, operator +

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Mathias

Mixing dynamic and static array does not work properly yet.

I compiled the following code with the latest trunk of FPC (revision 39062):

procedure Ausgabe(a: array of byte);
var
   i: integer;
begin
   for i := 0 to Length(a) - 1 do begin
     Write(a[i]: 4);
   end;
   WriteLn();
end;
procedure TForm1.Button1Click(Sender: TObject);
var
   a, b, c: array of byte;
   d: array[0..2] of byte = (6, 7, 8);
begin
   a := [1, 2, 3];
   Ausgabe(a);           // io.
   b := a + d + [123, 222];
   Ausgabe(b);           // error  --> Output:  1   2   3 123 222 123 222
   b := a + [123, 222];
   c := b + b;
   Ausgabe(c);           // io.
   Delete(c, 2, 2);
   Ausgabe(c);           // io.
   c := Concat(a, d, a); // io.
   Ausgabe(c);
   c := a + d + a;       // io.
   Ausgabe(c);
   //  d := [5, 6, 7]; // geht nicht
end;
Sven Barth
to Mathias
Mathias wrote
Mixing dynamic and static array does not work properly yet.

The "+" operator is currently not supposed to work for static arrays. Please report as a feature request.

var   a, b, c: array of byte;   d: array[0..2] of byte = (6, 7, 8); begin

[snip]

  //  d := [5, 6, 7]; // geht nicht end;

This is currently not supposed to work either. If you want that you can file a separate feature request report though that won't have a high priority.

Regards,
Sven