[fpc-pascal] Ideas for namespace implementation

Marcos Douglas md at delfire.net
Tue Jul 27 14:54:11 CEST 2010


On Tue, Jul 27, 2010 at 5:44 AM, "Vinzent Höfler"
<JeLlyFish.software at gmx.net> wrote:
>> On 26 July 2010 19:26, Thierry Coq <tcoq at free.fr> wrote:
>> >
>> > I see units as namespaces already existing: we use the unit names to
>> > prefix
>> > ambiguous function or variable names for example.
>>
>> Unit Names give very limited namespace support - which only applies to
>> types or procedures/functions or global variables (anything in the
>> interface section of a unit).
>
> And that sure is enough - unless you want to extend to Ada's package concept
> (which in fact is more than just "namespace") and even there you are not immune
> to name conflicts. I suppose you know that as you were the one who suggested it. ;)
>
> But then, IME (most) name conflicts are a sure sign of inproper names. Take the
> example of "constants.pas": What sort of constants shall I expect there? Screen sizes,
> color codes, electron mass or the gravitational constant?

You right about "constants.pas".
Then I would like to give other example: StrUtils.pas
What we expect in unit StrUtils or "Strings Utilities". Is very clear.
But we can't use this name. That is the problem (no for FPC's units
because we all know their names).

> Namespaces are a clutch added to C++ because being stuck with C-compilers
> they simply had no proper solution. Remember, in C _every_ visible identifier is in the same scope. There are no "units".
>


MD



More information about the fpc-pascal mailing list