[fpc-pascal] Case in Record

Anton Tichawa anton.tichawa at chello.at
Wed Oct 7 08:36:51 CEST 2009


On Wed, 2009-10-07 at 07:22 +0200, Jürgen Hestermann wrote:


> 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.

True. The second example has better style, though.

But the point is that X can be completely omitted.

E. g. you have the freedom to encode the information contained in X in
some other way. It might be derived from a name or a part number.

Anton





More information about the fpc-pascal mailing list