Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2004-10

Variable scope concurrency

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marc Santhoff

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

TIA,
Marc

Peter Vreman
to Marc Santhoff
Show quoted text 36 lines
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

Marc Santhoff
to Florian Klaempfl
Show quoted text 11 lines
Marc Santhoff wrote: > Am Do, den 14.10.2004 schrieb Peter Vreman um 07:49: > [..] > >>Correct > > > Wow, the shortest possible answer. :) No

LOL, but not to my question. I would have accepted "right" or the like ... ;)

Cheers,
Marc