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

Timothy Madden terminatorul at gmail.com
Wed Aug 22 12:48:52 CEST 2012


On 08/22/2012 11:30 AM, Sven Barth wrote:
> Am 21.08.2012 21:42, schrieb Jorge Aldo G. de F. Junior:
>> 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...
> 
> The compiler can not detect such collisions, because it stops searching
> for a symbol if it found a suitable one. This also explains why you need
> the "overload" directives in certain cases of cross unit overloading
> (because then the compiler will search for more). This is one of the
> reasons why the compiler can compile code so fast: It does not need to
> check all loaded units of a unit (and there are units that contain many
> uses).
> 
> So from me this gets a definit -1 in big letters.

All this discussion with a warning for duplicate symbols is not helpfull:
   - it is not backward compatible
   - as someone else in this thread said, it is possible to put the
current lookup rules to good use
   - it is not enough to solve the problem I am talking about in this
thread (that is, eliminate the risk of colisions when the compiler or
the libraries are upgraded).

Using aliases for imported units, and making them required on each
symbol reference, will not affect compilation speed or lookup for
unqualified names.

Lookup for qualified names is faster than lookup for unqualified names.

Regards
Timothy Madden





More information about the fpc-pascal mailing list