[fpc-pascal] why can't we define class operator for old fashion object type, but ok for 'advanced record' type?

Sven Barth pascaldragon at googlemail.com
Thu Aug 16 10:28:05 CEST 2018


Am 15.08.2018 um 17:29 schrieb Michael Van Canneyt:
>
>
> On Wed, 15 Aug 2018, Sven Barth via fpc-pascal wrote:
>
>>>
>>> But maybe you are using mode delphi ? If so, try separating out the 
>>> object
>>> definition in a separate unit which is not compiled in delphi mode. 
>> A global operator won't help at all as (currently) the operator won't 
>> be visible during the specialization. Only if the operator is visible 
>> during the *generic's* declaration it would be picked up.
>
> That is contrary to the class operator, which is also only visible during
> specialization, after all.
>
> Is there a reason for this behaviour ? 
The operator of a record is visible together with the record, however a 
global operator is not. When specializing the unit scope of the 
declaration of the *generic* is restored thus no helpers or global 
operators of the current scope are visible except they are part of the 
type parameter.
I do want to try to change this in the future, but I need to be careful 
to not open a different can of worms (as Delphi doesn't do it this way).

Regards,
Sven



More information about the fpc-pascal mailing list