[fpc-pascal]typed constants

Peter Vreman peter at freepascal.org
Thu Jan 2 14:43:17 CET 2003


> On Thursday 02 January 2003 04:28, Michael.VanCanneyt at Wisa.be wrote:
>
>> So the following will be allowed
>>
>> program recurs;
>>
>> Procedure doit (N : Integer);
>>
>> Const
>>   C : Integer = 1;
>>
>> Var
>>   A : Integer = 0;
>
> Is this a typo? This should be
>
> |A : Integer := 0;
>
> shouldn't it? I mean it is a variable, so you can only *assign* an
> initial value to it instead of setting it equal to some value.

Go and tell Borland about it, they use '=' for assigning enums. FPC
already supported that with ':='.

It's all about compatibility. When we are not compatible with Delphi we
get a lot of bug reports.


> Ok, one could argue, the (local) typed constant thing *is* a variable,
> too, but at least we *call* it constant, even if in real world it is
> not. IMO it would be more consistent to not allow a variable to be set
> with the "=" operator. Consider this:
>
> |Var
> |  A : boolean = C = D;
>
> Looks a little bit crazy to me.

That is also not allowed. You need to specify a constant value.






More information about the fpc-pascal mailing list