[Lazarus] const array syntax

Alexander Klenin klenin at gmail.com
Tue Jan 12 15:22:12 CET 2010


On Tue, Jan 12, 2010 at 23:59, Paul Ishenin <webpirat at mail.ru> wrote:
> Jürgen Hestermann wrote:
>>
>> That's an issue, yes. Although, in this case the constant "auto" could be
>> independend from the keyword "auto". So it would not fail. Instead constant
>> and array size would not be related in any way (although it appears like
>> that).
>
> I can't. How compiler will decide whether this is a constant 'auto' or a
> keyword inside the const declaration?

Of course. 'auto' was a bad idea. Either 'end', 'var' or some other
reserved keyword is preferable.

>>> I would go for
>>>  arr: [1..] of Integer = (1, 2, 3);
>
> Maybe, but this can lead to ocasional errors. What if developer forgot to
> write the paticular value on which program execution depends.
>
> I would use arr[] of Integer as in C. This would also simplify code porting

But also force lower bound to be always zero.
IMHO this is unnecessary restriction, although it might be ok
if implemented in addition to the auto-calculated upper bound.
I think having to write arr: [0..var] of Integer will not make porting
much harder,
especially compared to the horror of manual counting required now ;-)

-- 
Alexander S. Klenin




More information about the Lazarus mailing list