[Lazarus] record initialization

Jürgen Hestermann juergen.hestermann at gmx.de
Sat May 30 16:11:32 CEST 2015


when I try to initialize a record as in

----------------------------------------
var X : record
             A : Sizeint;
             B : boolean;
             C : Sizeint;
             D : boolean;
             E : Sizeint;
             F : boolean;
             G : Sizeint;
             H : boolean;
             end = (A : 0;
                    B : false;
                    C : 0;
                    D : boolean;
                    E : 0;
                    F : false;
                    G : 0;
                    H : false);
----------------------------------------

then this works as expected.
When omitting some entries from the end it works too:

----------------------------------------
var X : record
             A : Sizeint;
             B : boolean;
             C : Sizeint;
             D : boolean;
             E : Sizeint;
             F : boolean;
             G : Sizeint;
             H : boolean;
             end = (A : 0;
                    B : false;
                    C : 0;
                    D : boolean;
                    E : 0);
----------------------------------------

I only get a warning, that"Some fields coming after "E" weren't initialized".

But when I leave out variables in the middle or at the beginning as in:

----------------------------------------
var X : record
             A : Sizeint;
             B : boolean;
             C : Sizeint;
             D : boolean;
             E : Sizeint;
             F : boolean;
             G : Sizeint;
             H : boolean;
             end = (B : false;
                    C : 0;
                    D : boolean;
                    H : false);
----------------------------------------

then I get an error "Some fields coming before "B" weren't initialized" and it does not compile.

I found no words about this restriction in http://www.freepascal.org/docs-html/ref/refse23.html
Shouldn't it appear there?
It took me quite a while to find out why it did not compile
because omitting from the end works so why does it not work
when omitting from the beginning (or in the middle)?






More information about the Lazarus mailing list