[Lazarus] FPReport file names

Mattias Gaertner nc-gaertnma at netcologne.de
Wed Sep 13 21:17:34 CEST 2017


On Wed, 13 Sep 2017 18:09:40 +0200
Ondrej Pokorny via Lazarus <lazarus at lists.lazarus-ide.org> wrote:

>[...]
> I think you are wrong.

Partly. I just didn't tell the whole story.

> I didn't study how the compiler resolves the 
> identifiers internally, but when I developed dotted unit support for 
> CodeTools I did it so: I register all namespaces and subnamespaces from 
> known units (for uses clause) and used units (for implementation code) 
> and resolve the identifiers from left to right - easy and how it's 
> always been.

Yes, and I extended your code even further.

 
> In your example you always know if 'a' is a namespace or an identifier. 
> The identifier always wins agains a namespace:
>
> unit ns1.Unit1;
> interface
> var
>    A: string;
>    ns1: Integer;
> implementation
> initialization
>    ns1.Unit1.A := 'a'; // << error illegal identifier

Correct. But if 'ns1' is part of a namespace, you have to search the
namespace with the most dots.


> end.
> 
> unit ns1.Unit2;
> interface
> var
>    A: string;
>    ns1: Integer;
> implementation
> uses
>    ns1.Unit1; // error: duplicate identifier (bug in CodeTools: they 
> don't show an error here because they don't test agains identifier in 
> uses clause- but the compiler is correct)

Codetools is usually more tolerant than the compiler.


> initialization
>    ns1 := 1;
> end.
> 
> Everything looks like the compiler uses the same algorithm -> it first 
> resolves a then b then c and so on, it doesn't need to go backwards.

It's not so simple. See my example for Sven:
...
uses unitdots.unit1, unitdots;
type
  TPrgBright = unitdots.tbright;
  TPrgColor = unitdots.unit1.tcolor; <--
...

Mattias


More information about the Lazarus mailing list