Sign in Join

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

Mailing lists / fpc-devel / 2009-12

Record with dynamic array of same type

8 messages · 5 people ·

Reply by email Subscribe to this list Your subscription

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

Paul van Helden

Hi All,

In the beginning of this year I could compile this:

  TMyRecord = record
    Id: Integer;
    Name: String;
    ChildRecords: array of TMyRecord;
  end;

...but now with FPC 2.2.4 I get "Error: Illegal expression" on line 4

Why the change? (And if there is a good reason, could the error message be more descriptive?)

Regards,

Paul.

Reply by email

Jonas Maebe
to Paul van Helden
Paul van Helden wrote 11 lines
In the beginning of this year I could compile this: TMyRecord = record Id: Integer; Name: String; ChildRecords: array of TMyRecord; end; ...but now with FPC 2.2.4 I get "Error: Illegal expression" on line 4 Why the change?

I can't even compile it with FPC 2.0.4 (the oldest FPC version I have lying around, and which was released in August 2006). What was the previous FPC version that you used and which could compile the above?

(And if there is a good reason, could the error message be more descriptive?)

I guess it should be possible to give an error similar to what Kylix does:
tt.pp(9) Error: Type 'TMyRecord' is not yet completely defined

Jonas

Reply by email

Paul Ishenin
to Jonas Maebe
Jonas Maebe wrote 10 lines
> > TMyRecord = record > Id: Integer; > Name: String; > ChildRecords: array of TMyRecord; > end; I guess it should be possible to give an error similar to what Kylix does: tt.pp(9) Error: Type 'TMyRecord' is not yet completely defined

D2010 compiles this.

Best regards,
Paul Ishenin.

Reply by email

dmitry boyarintsev
to Jonas Maebe: I can't even compile it with FPC 2.0.4 (the oldest FPC version I have lying around, and…
Jonas Maebe wrote
I guess it should be possible to give an error similar to what Kylix does:  tt.pp(9) Error: Type 'TMyRecord' is not yet completely defined

if dynamic arrays are actually pointers, why the record should not be completely defined?
Isn't using dynamic array would be something similar to this:

PMyRecord =^TMyRecord;
TMyRecord = record
 Id: Integer;
 Name: String;
 ChildRecords: PMyRecord;
 ChildCount: Integer; // implicit dynamic array field.
end;

thanks,
dmitry

Reply by email

Jonas Maebe
to dmitry boyarintsev
dmitry boyarintsev wrote 8 lines
On Wed, Dec 9, 2009 at 5:22 PM, Jonas Maebe wrote: > I guess it should be possible to give an error similar to what > Kylix does: > tt.pp(9) Error: Type 'TMyRecord' is not yet completely defined if dynamic arrays are actually pointers, why the record should not be completely defined?

I don't know why Kylix refuses it. It's true that in theory it could be compilable (and apparently some very old FPC version did and very new Delphi version does compile it).

Jonas

Reply by email

dmitry boyarintsev
to Jonas Maebe
Jonas Maebe wrote
I don't know why Kylix refuses it. It's true that in theory it could be compilable (and apparently some very old FPC version did and very new Delphi version does compile it).

It seems that it's "fixed" in 2010 only, because the structure cannot be compiled by Turbo Delphi.

thanks,
dmitry

Reply by email

Marco van de Voort
to dmitry boyarintsev

In our previous episode, dmitry boyarintsev said:

Show quoted text 5 lines
> I don't know why Kylix refuses it. It's true that in theory it could be > compilable (and apparently some very old FPC version did and very new Delphi > version does compile it). It seems that it's "fixed" in 2010 only, because the structure cannot be compiled by Turbo Delphi.

2009 also eats it

Reply by email

Paul van Helden
to Jonas Maebe: I can't even compile it with FPC 2.0.4 (the oldest FPC version I have lying around, and…
Show quoted text 11 lines
I can't even compile it with FPC 2.0.4 (the oldest FPC version I have lying around, and which was released in August 2006). What was the previous FPC version that you used and which could compile the above? > (And if there is a good reason, could the error message be more > descriptive?) I guess it should be possible to give an error similar to what Kylix does: tt.pp(9) Error: Type 'TMyRecord' is not yet completely defined

Sorry, I was confused. It must have been something I tried some months ago and abandoned. The source file is more recent than the compiled executable.
I do hope someday soon it will be possible with FPC to TMyRecord = record

   Id: Integer;
   Name: String;
   ChildRecords: array of TMyRecord;

end;
:-)

Reply by email