[fpc-pascal] modeswitch multihelpers precedence problem
Michael Van Canneyt
michael at freepascal.org
Tue Mar 10 08:37:34 CET 2020
On Tue, 10 Mar 2020, Ryan Joseph via fpc-pascal wrote:
>> On Mar 10, 2020, at 11:57 AM, Anthony Walter via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
>> To demonstrate, if I have MyUnit.pas that defines a string type helper with EndsWith() and an IntToStr() function then consider the following code:
>> program Test;
>> MyUnit, SysUtils;
>> 'hello'.EndsWith('lo'); // invokes MyUnit.TStringHelper.EndsWith()
>> IntToStr(12); // invokes SysUtils.IntToStr()
> I think the problem here may be because SysUtils doesn't enable the mode
> switch. In that example above I would expect EndsWith to be used from the
> last unit, that is SysUtils. If you remake the example without SysUtils
> and define the type helpers in 2 units that both enable multihelpers does
> it work correctly?
In that case the mode switch would be wrong. As a developer of a type helper,
you should not have to care about this: you just define a type helper. You
should not have to say 'I will allow this type helper to be used with other
type helpers'; That should always be so.
I imagine that the type helper is meant for the person wanting to use multiple
type helpers: it says to the compiler 'please look for more type helpers'.
More information about the fpc-pascal