[fpc-pascal] type helper default property
Sven Barth
pascaldragon at googlemail.com
Thu Jan 17 22:42:39 CET 2019
Am 17.01.2019 um 13:17 schrieb Mattias Gaertner via fpc-pascal:
> Hi,
>
> For example:
> type
> THelper = type helper for string
> function GetItems(Index: word): word;
> property Items[Index: word]: word read GetItems; default;
> end;
>
> Delphi forbids this with "'default' directive not allowed in record
> helper type".
> FPC ignores it. Aka aString[1] has still the normal meaning.
>
> Same for arrays, double, integers.
>
> Is this an oversight, or has FPC some use for the default directive?
For now I'd say that it's an oversight. Delphi allows it for class and
record helpers, but not for helpers for primitive types. In theory we
could allow it for non-array and non-string types (aka those that don't
have an internal [...] "operator"). On the other hand we can simply
forbid "default" for primitive type helpers like Delphi does...
Regards,
Sven
More information about the fpc-pascal
mailing list