[fpc-pascal] Re: How to avoid namespace name clashes after USES ?

Jorge Aldo G. de F. Junior jagfj80 at gmail.com
Tue Aug 21 13:57:45 CEST 2012

I am trying hard to think of a situation where unit prefixes are not
enough, but its hard to see.

2012/8/21 Timothy Madden <terminatorul at gmail.com>:
> On 08/21/2012 02:17 PM, DaWorm wrote:
>> Very tedious, but you could create a wrapper unit and/or class for each
>> library, and expose a prefixed name instead of the original.
> Very ingeniuos, I believe this is as close to a solution as I can get
> for now.
> But there are still a few probles I can see:
>    - there is no way to "prefix" symbols within a unit, that I know of.
>      Symbols may only be prefixed by the unit name directly. Is there a
>      sort of a "namespace" in Pascal ?
>    - if I make a wrapper unit around the third-party one, there is
>      alredy little need for a prefix, since I can expose only the
>      symbols I know of and that I use.
>    - I find it even more tedious to do the same thing with the System
>      unit or the standard Pascal units.
> And then, if wrapper unit publicly uses the third-party unit, doesn't
> that mean that all symbols in the thrid-party unit are now automatically
> exposed and public in the wrapper unit ?

Nope, you can "uses" in the implementation section AND if a unit uses
a third unit, the third unit identifiers are not visible in the

Unit a:
Uses b;

Unit b;
Type z=integer;

program c;
uses a;
  h: z;

Type Z is not visible in program c, generating an error.

> If so, is there a way to expose and make public the types, classes,
> variables and functions from a private (implementation) unit ?
> Thank you,
> Timothy Madden
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Types, consts, variables, classes, functions, procedures etc, are
public if they are defined in the interface section, and private if
they are defined in the implementation section.

A unit/program imports the interface definitions of another unit if it
uses then in their own interface section.

More information about the fpc-pascal mailing list