[fpc-pascal]typed constants

Vinzent Hoefler JeLlyFish.software at gmx.net
Thu Jan 2 14:59:25 CET 2003


On Thursday 02 January 2003 08:43, Peter Vreman wrote:
> > On Thursday 02 January 2003 04:28, Michael.VanCanneyt at Wisa.be wrote:
>
> >> 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 ':='.

*eeek* In Delphi you can write the following?

|var
|  X : some_enum = enum_value;

I thought, this kind of syntax is only allowed for typed "constants"?

<cite>
|> I recommend to the compiler guys (when schedule permits) implementing
|> the compiler initilization of local variables (which have an
|> initialization value declared)...that is, it gets initialized when it
|> gets pushed onto the stack.
|
|The matter is being discussed by the core members.
|The response I've had till now indicate that probably we'll implement 
|it as initialized variables.
</cite>

So I did not understand the last sentence correctly?

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

Even if it is right..., yes I know. So "initialized variables" are 
already supported in Delphi and you simply have to be compatible?

> > 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.

Well, at least with

|const
|  C = 5;
|  D = 6;

the line above should legally evaluate to False as initial value for A. 
However, I even see no reason why

|procedure Do_It (C, D : Integer);
|var
|  A : boolean := C = D;

shouldn't be allowed for initialization.


Vinzent.

-- 
Mathematicians do it in theory.




More information about the fpc-pascal mailing list