[fpc-pascal] Case in Record
Vincent Snijders
vsnijders at vodafonevast.nl
Wed Oct 7 09:19:39 CEST 2009
Jürgen Hestermann schreef:
> Therefore, there is absolutly no difference between
>
> TFigure = record
> X : TShapeList;
> case TShapeList of
> Rectangle: (Height, Width: Real);
> Triangle: (Side1, Side2, Angle: Real);
> Circle: (Radius: Real);
> Ellipse, Other: ();
> end;
>
> and
>
> TFigure = record
> case X : TShapeList of
> Rectangle: (Height, Width: Real);
> Triangle: (Side1, Side2, Angle: Real);
> Circle: (Radius: Real);
> Ellipse, Other: ();
> end;
>
> It ends up in the same record and also the programmer does not see any
> difference. He can store whatever he wants in X in both cases. It has no
> influences on the variants.
IIRC, there is a difference. With the second declaration the compiler can add a
run-time check that the correct memebrs are accessed based on the value of X.
Unfortunately, I cannot find the compiler switch.
Vincent
More information about the fpc-pascal
mailing list