Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2019-01

type helper default property

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mattias Gaertner

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?

Mattias

Reply by email

Sven Barth
to Mattias Gaertner
Mattias Gaertner wrote 16 lines
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

Reply by email

Mattias Gaertner
to Sven Barth
Show quoted text 9 lines
[...] > 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...

Thanks!

Mattias

Reply by email