[Lazarus] const array syntax

Jürgen Hestermann juergen.hestermann at gmx.de
Tue Jan 12 10:18:25 CET 2010



> Alexander Klenin schrieb:
> 1) Proposed syntax seems somewhat suboptimal. Historically, Pascal
> used redundancy and keywords to minimize the chance of errors and
> make diagnostics easier. In that spirit, I think some active indication
> of arbitrary upper bound is preferable to a mere omission:
> IDECommandStrs: array[0..*] of TIdentMapEntry = (
> IDECommandStrs: array[0..auto] of TIdentMapEntry = (
> IDECommandStrs: array[0..end] of TIdentMapEntry = (

I would vote for "auto". But beside finding a good syntax I am not sure whether it is so easy to implement such automatic border calculation. If the size is defined before the declaration, then the compiler can reserve the required space. With automatic calculation it would have to store the array data somewhere else with more or less infinite (at least unknown) space requirement. I am not sure whether this can be achieved easily and whether it's worth the effort.

> 2) We should think through and specify how multi-dimensional arrays should work:
> matrix: [1..auto, 1..auto] of Integer = ((1, 2, 3), (4, 5, 6));

Well, if it works with one dimension it should work with more too. The only problem would be, that after the first dimension is completed for the first time, the found size has to be fixed for all other levels:

matrix: [1..auto, 1..auto] of Integer = ((1, 2, 3), (1, 2, 3), (1, 2, 3));

would be ok but

matrix: [1..auto, 1..auto] of Integer = ((1, 2, 3), (1, 2), (1, 2));

has to be rejected (cause an error).






More information about the Lazarus mailing list