<div dir="auto"><div class="gmail_quote" dir="auto"><div dir="ltr">Am Do., 17. Jan. 2019, 13:10 hat Mattias Gaertner via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>> geschrieben:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
A type helper for a string can add a constructor.<br>
But how it can be used differs between FPC and Delphi.<br>
<br>
For example:<br>
<br>
{$modeswitch typehelpers}<br>
type <br>
  THelper = type helper for string<br>
    constructor Creator(i: integer);<br>
  end;<br>
<br>
var<br>
  s: string;<br>
begin<br>
  string.creator(3); <br>
  // allowed in delphi+fpc, creating a new string<br>
<br>
  s.creator(3);<br>
  // fpc: same as above, creating a new string<br>
  // delphi: error: Cannot call constructors using<br>
  //         instance variables<br>
end;<br>
<br>
IMO the fpc way is inconsistent to how constructors work for classes<br>
and records. A constructor usually only creates something when called<br>
with the type (e.g. TObject.Create), while behaving like a normal<br>
function when called with an instance (e.g. obj.create).<br>
<br>
Is this a bug or by design?<br></blockquote></div><div dir="auto"><br></div><div dir="auto">I would say it's a bug as in my opinion it should behave as with classes. </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div class="gmail_quote" dir="auto"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"></blockquote></div></div>