RES: [fpc-pascal] dot within unit file name
Vinzent Höfler
JeLlyFish.software at gmx.net
Fri Jan 18 18:08:01 CET 2008
Daniël Mantione wrote:
> Op Fri, 18 Jan 2008, schreef Vinzent Hoefler:
>
>> On Friday 18 January 2008 16:04, Michael Van Canneyt wrote:
>>> On Fri, 18 Jan 2008, Daniël Mantione wrote:
>>>> Op Fri, 18 Jan 2008, schreef Michael Van Canneyt:
>>>>> To the user, it may appear as a bunch of dots. To the compiler,
>>>>> it doesn't know how to map the a.b.c.d:
>>>>
>>>> Well, with normal Pascal rules, you cannot declare a variable with
>>>> the same name as a unit you use, because a unit is also an
>>>> identifier. Most logical would be to reject the declaration of
>>>> variable A in this case due to a duplicate identifier.
>>>
>>> No, because the unit identifier is a.b.c, not a.
>>>
>>> It has to be, otherwise units windows.messages and windows.records
>>> would both have identifier windows, leading to an error.
>>
>> Why? It would be in the uses clause, not in the declaration part. So
>> it's not "declaring" the same identifier twice.
>
> Search for "unit identifier" in TP/Delphi books. "uses x" declares x as
> unit identififier in the symtable of the current program/unit. So, it is
> declared twice (with reason).
Well, but at that time there would be no confusion between a
"Windows.Messages" and "Windows.Constants". Both have to be units at
that point.
Maybe my view is skewed too much by the use of Ada where even a function
declares a "record identifier". In Ada it is even possible to do:
---
procedure Test is
X : Integer;
procedure B is
X : Integer;
begin
X := 1;
Test.X := 2; -- references X of "Test" procedure
end B;
begin
X := 3;
end Test;
---
Vinzent.
More information about the fpc-pascal
mailing list