[fpc-pascal] Syntax problem with first unit

Mehmet Erol Sanliturk sanliturk at ttnet.net.tr
Sun Apr 5 19:10:04 CEST 2009

Tomas Hajny wrote:
> Note that although having the unit named equally to a function, procedure
> or a variable defined within the unit (or elsewhere) is not really
> advisable, it is possible, but you need to take scoping rules into account
> when trying to access the function, procedure or variable. In your
> particular case, you would need to use DebugPrint.DebugPrint (your
> parameters) in order to tell the compiler that you refer to the function
> DebugPrint stored within unit DebugPrint referenced in the "uses" section.
> That's also why the compiler suggested that you should use '.' after
> DebugPrint.
> Tomas
The following addition may be made to the above explanation for a little 
more clarification :

When compiler scanned the assignment statement := , it found the name 
DebugPrint .
Within the scope of the program DebugPrint is a unit name whereas there 
should be
a variable name . For that reason , the compiler assumed that there 
should be a qualification of a variable name by the unit name such as

 ... := DebugPrint . x ...

Instead of finding a period and variable name after the unit name 
DebugPrint , it found a left parenthesis .

Due to this , it gave the message  ... Expected . ( period ) but found ( 
left parenthesis ) .

Thank you very much .

Mehmet Erol Sanliturk

More information about the fpc-pascal mailing list