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

Vinzent Höfler JeLlyFish.software at gmx.net
Fri Jan 18 18:27:26 CET 2008


Michael Van Canneyt wrote:

> You are wrong. It does not compile, neither in delphi, nor in FPC.
> D is not found, because 'A' resolves to the local a, and then the 
> search is stopped.

Ok, I think I got it. It's probably the same reason why in

---
procedure Foo (const A : My_Type); overload;
procedure Foo (const B : Some_Type); overload;

procedure Bar;
var
    A : My_Type;
    B : Some_Type;
begin
    Foo (A); // works
    Foo (B); // works
end;

procedure Foobar;
    // declare "Another_Type" locally
    procedure Foo (const C : Another_Type); begin ... end;

var
    A : My_Type;
    C : Another_Type;

begin
    Foo (C); // works
    Foo (A); // wrong type!
end;
---

the last call does not work (unless I write "unitname.Foo (A)" there).

BTW, the same happens with overloaded methods in classes when I try to 
extend the class: The overloaded methods of the parent class are 
suddenly not available anymore once I declare another overloaded method.
This actually happened to me when I tried to extend the XMLConfig class 
for "Double" types. Once I declared "SetValue (Double)" in the derived 
class, I would have needed typecasts to access "SetValue (Integer)" and 
"SetValue (String)" in virtually every call. The other solution would 
have been to redeclare the overloaded methods in the derived class, I guess.

Well, writing about all that, I come to the conclusion that the Pascal 
scoping rules can really suck from time to time. ;) No plan to change 
that, though, I suppose?


Vinzent.




More information about the fpc-pascal mailing list