[fpc-pascal] How to avoid namespace name clashes after USES ?
Jorge Aldo G. de F. Junior
jagfj80 at gmail.com
Tue Aug 21 23:29:56 CEST 2012
the alias is the fully qualified function name :
you dont need alias, cause you cant have two units with the same name,
so you have two different fully qualified function names.
The warning would simply point out that there are two functions with
the same name and parameters in the current scope, because thats the
only possible conflict.
Requiring all functions to be allways fully qualified will make the
most commom case worse than current implementation just to be better
for the uncommon case. This is a step back, not forward...
2012/8/21 Marcos Douglas <md at delfire.net>:
> On Tue, Aug 21, 2012 at 5:19 PM, Marcos Douglas <md at delfire.net> wrote:
>> On Tue, Aug 21, 2012 at 4:42 PM, Jorge Aldo G. de F. Junior
>> <jagfj80 at gmail.com> wrote:
>>> 2012/8/21 Marcos Douglas <md at delfire.net>:
>>>> On Tue, Aug 21, 2012 at 3:08 PM, Marco van de Voort <marcov at stack.nl> wrote:
>>>>> In our previous episode, Marcos Douglas said:
>>>>>> I proposed this sintaxe:
>>>>>> uses my_long_unit_name as my;
>>>>> This doesn't protect any better, since
>>>>> the new unit might also define "my".
>>>> True, but using this sintaxe I can use an alias to the third-party
>>>> units so, I can use my own names to reference identifiers that I can
>>>> not change.
>>>> The collision still can exists? Yes, but in that case the programmer
>>>> would be wrong, not third-party unit names or because the compiler not
>>>> The third-party could use a better and bigger name like "XyzNetSocket"
>>>> but I could use just "net" (uses XyzNetSocket as net), for example.
>>>> IMHO this is more sophisticated than pure namespace.
>>> Instead of implementing the half-assed C++ namespace model, just add
>>> to the compiler a warning when it detects that there is a collision in
>>> the current scope (two functions with the same parameters from
>>> different units that can be called from the scope being inspected). I
>>> believe function overload alread provides the necessary hooks, but i
>>> cant do it because i have zero experience with FPC sources...
>> Well, a good idea but this is another thing...
>> This is do not resolves the problem if I have a third-party unit with
>> the same name that other.
> If I can use an alias to ref an unit, the names could be bigger
> because I can ref them only using the alias.
> Extend the concept:
> if nevertheless we have same names in two libs (eg: foounit), we could use:
> foounit as f1 in '/path_1/foounit.pas',
> foounit as f2 in '/path_2/foounit.pas';
> IMHO, would be PERFECT.
> Marcos Douglas
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
More information about the fpc-pascal