[fpc-devel] Allow record helper inheritance in Delphi mode

Sven Barth pascaldragon at googlemail.com
Wed Sep 13 22:08:50 CEST 2017


On 12.09.2017 22:21, Ondrej Pokorny wrote:
> On 29.08.2017 7:54, Sven Barth via fpc-devel wrote:
>> This will not be enabled by default. If anything a modeswitch will be
>> added so that users are aware that what they'll write will not be
>> compatible with Delphi.
> 
> Any chance to get the (last) patch in issue #32355 reviewed? Somehow I
> have the feeling that I always hear "patches are welcome" but
> consequently my patches are ignored and then they just get forgotten if
> I don't remind several times.

Ever thought that I might not work on FPC every day yet alone review
patches?
Anyway, I had looked at your patch last Friday, but after some thinking
I came to the conclusion that I definitely don't want the typehelpers
modeswitch to enable inheritance on record helpers in mode Delphi cause
that would be some unexpected sideeffect on that switch. However to
implement this correctly I'll need to store the helper type in the PPU.
It's nothing big, just something I need to find the time for...

> Btw. when you are so strict about disabling helper inheritance due to
> Delphi compatibility why do you allow C-like operators in Delphi mode by
> default?
> 
> program Cop;
> 
> {$mode delphi}
> 
> var
>   I: Integer;
> begin
>   I := 0;
>   I += 1;
> end.
> 
> ... and they even have their COPERATORS directive.

Two things:
1. If you compile with -n (and -Fupath/to/rtl) you'll see that it is not
Delphi mode that enables the C-operators, but the default fpc.cfg (and
no, I don't know who had the idea to enable that as default; maybe it
was originally default and then moved to a directive, but kept set by
default using the fpc.cfg... - for this however see the next point)
2. Backwards compatibility. In the past quite some features were added
without much respect for the modes (e.g. the "<<" and ">>" operators as
aliases for "shl" and "shr" work in any mode and can't be disabled
anyway), so some things are simply kept that way to avoid disruptions of
existing code while the implementation of new features became stricter
in the last 6 years or so.

Regards,
Sven



More information about the fpc-devel mailing list