cascaded record constants lazarus / 62-General ---------------------------------------------------------------------- lt.col.blair · 2014-10-24 17:33 Hi, Is it possible to define constants that are made up of records which again contain records? My structures are like this: Code: [Select]RDartPolar = record   Radius: NRadius;   Field: NField; end; RBoardPosition = record   BoardPos: RPolar;   RectPos: TPoint; end; const   PolarNULL: RDartPolar=(Radius: radMissed; Field: fld20);   PointNULL: TPoint = (X: -1000; Y: -1000);   DartNULL: RBoardPosition=(BoardPos: PolarNULL; RectPos: PointNULL); //raises compiler error '"(" expected but identifier PolarNULL found.' Is this an illegal construction or do I have some other error in my code? ---------------------------------------------------------------------- Blaazen · 2014-10-24 21:12 Isn't it type mismatch? RBoardPosition.BoardPos is type RPolar while PolarNULL is type RDartPolar. ---------------------------------------------------------------------- lt.col.blair · 2014-10-25 12:22 Sorry, that was a typo in my post - happens, when you copy paste one part and type the other... In my original code the BoardPos is also defined as RDartPolar. ---------------------------------------------------------------------- User137 · 2014-10-25 13:31 Well, i tried at least. Suspecting compiler just won't allow it? I went a bit further but it's giving me a vague "illegal expression", putting cursor ^ here: (BoardPos: (Radius: PolarNULL.Radius^; Field: PolarNULL.Field); Code: [Select]  NRadius = single;   NField = string;   RDartPolar = record     Radius: NRadius;     Field: NField;   end;   RBoardPosition = record     BoardPos: RDartPolar;     RectPos: TPoint;   end; const   radMissed = 1;   fld20 = '20';   PolarNULL: RDartPolar = (Radius: radMissed; Field: fld20);   PointNULL: TPoint = (X: -1000; Y: -1000);   //DartNULL: RBoardPosition = (BoardPos: PolarNULL; RectPos: PointNULL);   DartNULL: RBoardPosition =     (BoardPos: (Radius: PolarNULL.Radius; Field: PolarNULL.Field);      RectPos: (x: PointNULL.x; y: PointNULL.y)); ---------------------------------------------------------------------- taazz · 2014-10-25 13:36 It has to do with writable constants that FPC supports. Although the default is not writable the compiler will not allow to use record constants as values for other record constants. ---------------------------------------------------------------------- marcov · 2014-10-26 09:27 Probably the reason that the compiler does this is because of equality. If a structured constant A could be added to a constant C (say as field B)   then C.B<>A since they are located on a different address.