What happens, if you declare them as types insteads of Const?You mean var declaration in mode {$mode objFPC} which allows initializing variables just in its declaration?
To my mind, the "Const" is the problem.
This rather puzzles me, can anyone explain the differences between the following variable declarations, the first two work fine, the third fails with "plotter.pas(51,45) Fatal: Syntax error, "(" expected but "identifier COLRED" found"Because typed constants are not true constants and therefore cannot be used to initialize variables. This requires historical knowledge of typed constants from the days of Turbo Pascal, because Free Pascal values compatibility more than sensibility. Not necessarily a bad thing as this helps porting old Turbo Pascal code. And because there's no way to declare a true record constant, the parser expects "(" as it knows that's the only way to initialize a record var/const, i.e. by specifying and filling the fields one by one.
I find it strange how the original form of initialization I tried, the one that fails with typed constants, is not documented anywhere where I can find it. I am talking about, eg -It was documented by Sven in his mailing list announcement
var x:array[0..3] of integer =(1,2,3,4); // Static y:array of integer =(1,2,3,4); // dynamic
While I did not quite understand the process (I do now) its still a very convenient way to work. Is it frowned upon, not officially supported, whatever ? I'd like to add something to the wiki ....
but perhaps has not made it yet into the official documentation anywhere.Dynamic array constant expressions (https://www.freepascal.org/docs-html/current/ref/refsu14.html#x38-550003.3.1).
but perhaps has not made it yet into the official documentation anywhere.Dynamic array constant expressions (https://www.freepascal.org/docs-html/current/ref/refsu14.html#x38-550003.3.1).
And isn't it official?
Yes, it is. My problem was I though I was making a static array (the compiler gets everything it needs to define the structure at run time!). Now I see that a bit more clearly, yes, it is documented for a dynamic array. But not a static one I suggest ?
Further, that page does not mention things like Insert(), Delete(), Concat() also announced in PascalDragon's mailing list post of 2018.