RES: [fpc-pascal] dot within unit file name

Vinzent Hoefler JeLlyFish.software at gmx.net
Fri Jan 18 16:23:20 CET 2008


On Friday 18 January 2008 15:50, Michael Van Canneyt wrote:
> On Fri, 18 Jan 2008, Vinzent Hoefler wrote:
> > On Friday 18 January 2008 15:19, Michael Van Canneyt wrote:
> > > > I saw this week a CodeGear Guy in a cg ng talking about that.
> > > > In Win32 its is Just dots in the name, nothing else.
> > >
> > > If he said that, he is totally braindead and doesn't have a clue
> > > about what he is talking.
> >
> > Well, the discussion and explanation that have been provided so
> > far, back up that braindead guy's statement.
>
> Of course not:
>
> tell me, what does a.b.c.d mean if you have a record a with field b,
> and you have a uses a.b.c in your uses clause ?

The magic word would be "scope" here. It's the same as with using two 
different units including the same identifier twice.

In Ada, you have to explicitely resolve the ambiguity by specifying the 
full name, in Pascal the last encountered scope counts, so in your 
example:

> so
> ----------------------------
> unit a.b.c;
>
> interface
>
> Var
>   D : Integer;
[...]
> unit test;
>
> interface
>
> uses a.b.c;
>
> Type
>   T = record
>    b : integer;
>   end;
>
> Implementation
>
> var
>   A : T;
>
> begin
>   A.b.c.d:=3;// ???
> end.
> ----------------------------

the variable A would take precedence (as you've stated).

> 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:
>
> 1. Scoping rules dictate that the first match is the variable a.
>    So, it finds a as a variable.

Correct.

> 2. then it finds b in the fields of T. OK, it's on the right track!
> 3. But then it looks for C, but doesn't find it -> error, what now ?

Running up the scope until the identifier is either found or not.


Same with:

---
unit
   A;

var
   C : ...
   D : ...
---

---
function Blubb;
   A : Record_Type;
begin
   A.D :=
   A.C :=
end
---

AFAIK this would be perfectly compilable already. (I'm in a hurry right 
now, but I guess, you catch my drift.)



Vinzent.



More information about the fpc-pascal mailing list