[fpc-devel] Overloading standard functions

Виктор Матузенко vitek03 at gmail.com
Wed Jun 19 15:55:54 CEST 2019


ср, 19 июн. 2019 г. в 15:34, Marco van de Voort <fpc at pascalprogramming.org>:

>
> If the documentation lists the function as being in "system.fpd" that is
> probably it. You can look at that file (rtl/inc in the sources) to get
> an idea.
>

Ok, thanks.


> First, where would be the breakage? Now it works with and without overload?
>

If I write a unit that overloads the Pos function and code that uses the
unit
and calls standard version of Pos without namespace prefix, than this code
will be broken if Pos becomes builtin.

(It just will not compile the code and the error "Incompatible type" is not
clear
report the real problem.)

Now the cross unit overload does work for functions declared with the
"overload"
keyword and does not without.


>
> Second, while the chances are low, there are no guarantees. Avoid overly
> complex layering of the same symbol if you are afraid of this.
>

I am not a gambler, I ask what is guaranteed.

The Pos is just an example. I can change it to any other symbol: Foo,
Default, Writeln, GetHash, DoSomething, StrToUtf8 etc. My general
question is: as a library developer which symbols can I declare to be sure
that user of the library will not face conflicts with standard declarations,
FPC RTL etc (and how to do the declarations properly)?

The answer I see: none because any identifier may become "builtin",
start to hardly conflict with any declarations with the same name and
become PITA for code maintainer.

Pity.

-- 
Victor Matuzenko (Виктор Матузенко)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20190619/7f82ef24/attachment.html>


More information about the fpc-devel mailing list