> On Jun 10, 2019, at 9:25 AM, Sven Barth via fpc-devel 
> <[email protected]> wrote:
> 
> The operator for assigning one class instance to another exists and is 
> internal thus it is not allowed to be overloaded. 
> 

Is that true for binary operators also? The same principle could apply to them 
also and perhaps solve the problem you posted below.

operator + (aLeft, aRight: TSomeClass): TSomeClass;
begin
  aLeft.DoSomething(aRight);
  Result := aLeft;
end;

var
  a, b, c: TSomeClass;
begin
  a := TSomeClass.Create;
  b := TSomeClass.Create;
  c := a + b;
  a.Free;
  b.Free;
  c.Free; (* boom! *)
end.

Regards,
        Ryan Joseph

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

Reply via email to