[Lazarus] const array syntax

Duncan Parsons D.Parsons at seamsltd.com
Wed Jan 13 10:38:33 CET 2010


Must confess, I feel "arr:[0..end] of " makes more sense to me than use of "var" or "..]" The latter suggests something forgotten or a typo.

Pascal isn't about forgetting things or typos, indeed one of the reasons it is the language it is, is because of it's clarity and attention to overall readability. Yes, there are some peculiarities to do with pointer dereferences, but generally things are very accessible without prior detailed knowledge.

:shrug:

Just another opinion into the mix..
DSP

-----Original Message-----
From: Alexander Klenin [mailto:klenin at gmail.com] 
Sent: 12 January 2010 14:22
To: Lazarus mailing list
Subject: Re: [Lazarus] const array syntax

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

--
_______________________________________________
Lazarus mailing list
Lazarus at lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus




More information about the Lazarus mailing list