[Lazarus] Support for dotted unit name

Mattias Gaertner nc-gaertnma at netcologne.de
Fri Nov 4 08:17:21 CET 2011


On Thu, 03 Nov 2011 19:46:01 -0400
Rich Saunders <saunders.richard.p at gmail.com> wrote:

> On 11/3/11 7:03 PM, William Oliveira Ferreira wrote:
> > Sorry about my low knowlegde, maybe i am the most slow-learning mailer
> > of this list but i don't understand the advantage of using dots on
> > unit name. Could someon explain it to me?
> 
> Say you use a bunch of units where XXX is defined multiple times, once
> in each unit.
> 
> If you refer to XXX alone the actual XXX being referred to is determined
> by the search logic of the compiler which is governed by the scope rules
> within your unit and by the order of the uses clause. So arbitrary
> changes in the unit ordering can change the semantics of your code.
>  
> But if you really want to be sure that UnitX.XXX is the XXX being
> referenced you need to refer to XXX with the unit name prefix to ensure
> that.
> 
> This happens to me when I declare a method of a class as Inc to
> increment some field value in the class. Within the Inc method I need to
> call System.Inc to actually do the incrementing. Without the System
> prefix I would get recursion since the Inc method would call itself.

This is the explanation for using unitname.identifier, which worked
since many years.

Dotted unit name means dots in the unit name itself. For example
an.example.pas. I don't know a good example.


Mattias




More information about the Lazarus mailing list