Am Do., 17. Jan. 2019, 13:10 hat Mattias Gaertner via fpc-pascal <
[email protected]> geschrieben:

> Hi,
>
> A type helper for a string can add a constructor.
> But how it can be used differs between FPC and Delphi.
>
> For example:
>
> {$modeswitch typehelpers}
> type
>   THelper = type helper for string
>     constructor Creator(i: integer);
>   end;
>
> var
>   s: string;
> begin
>   string.creator(3);
>   // allowed in delphi+fpc, creating a new string
>
>   s.creator(3);
>   // fpc: same as above, creating a new string
>   // delphi: error: Cannot call constructors using
>   //         instance variables
> end;
>
> IMO the fpc way is inconsistent to how constructors work for classes
> and records. A constructor usually only creates something when called
> with the type (e.g. TObject.Create), while behaving like a normal
> function when called with an instance (e.g. obj.create).
>
> Is this a bug or by design?
>

I would say it's a bug as in my opinion it should behave as with classes.

Regards,
Sven

>
_______________________________________________
fpc-pascal maillist  -  [email protected]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to