[Lazarus] Extending TRect breaks Lazarus
Florian Klaempfl
florian at freepascal.org
Sat Nov 7 09:08:21 CET 2015
Am 07.11.2015 um 06:42 schrieb Ondrej Pokorny:
>
> Do not forget that you can overload operators! In particular you can
> overload the comparison operator to return a record, so your
> "with a=somerecord do" can already be a valid pascal code now:
>
> *type**
> ** TMyRec = record**
> ** I: Integer;**
> ** end;**
> **
> ** TMyResult = record**
> ** Res: Integer;**
> ** end;**
> **
> **operator = (z1: TMyRec; z2 : TMyRec) b : TMyResult;**
> **begin**
> ** Result.Res := z1.I+z2.I;**
> **end;**
> **
> **var**
> ** m1, m2: TMyRec;**
> **begin**
> ** m1.I := 10;**
> ** m2.I := 1;**
> ** with m1=m2 do**
> ** writeln(Res);**
> ** readln;**
> **end.*
>
> The assignment operator would be better, since it doesn't return a value
> (in pascal, of course) and thus cannot be used in a with statement now:
Good that we removed another "great" language extennsion already years
ago, the support for a C-like assignment operator which returns a result
:)))
More information about the Lazarus
mailing list