[fpc-pascal] Variable scope concurrency

Peter Vreman peter at freepascal.org
Thu Oct 14 07:49:23 CEST 2004


> Hi,
>
> I wonder what happens, if there are two variables with exactly the same
> name in scope, when one is in the interface part of one unit as a global
> and the other is in the implementation part of the crrent unit.
>
> When the variable name is adressed inside a procedure:
>
> unit one;
> uses two;
> ...
> implementation
> var
> 	mydoublevar: integer;
>
> procedure anything;
> begin
> 	mydoubledvar := 0;
> end;
>
> end.
>
> unit two;
> interface
> var
> 	mydoubledvar: integer;
> ...
> end.
>
> Which one wins?
>
> Is there a syntactic definition in the pascal language for this case and
> how does fpc handle it?
>
> My feeling tells me the "nearer" one should, in unit one in the
> example...

Correct






More information about the fpc-pascal mailing list