[Lazarus] 'with' is evil, isn't it?

Alexander Klenin klenin at gmail.com
Fri Aug 5 14:52:12 CEST 2011


On Fri, Aug 5, 2011 at 22:04, Luca Olivetti <luca at wetron.es> wrote:
>> Unfortunately, "with a = b do" is already a valid operator in FPC,
>> with different meaning.
>
> What does it mean?
>
> I tried
>
> procedure Test;
>  type tr = record
>             f1,f2:integer;
>           end;
>  var r:tr;
> begin
>  with a=r do;
> end;
>
> and trying to compile it
>  "Error: Operator is not overloaded"
>  "Error: Expression type must be class or record type"
>
> Same error even if I define a:tr.

I thought that you could overload opertator =:

type T = record  x, y: Integer; end;
operator =(A, B: T): T; begin Result := a; end;
var a, b: T;
begin
  with a = b do Writeln(x);
end.

However, FPC forbids overloading of "=" with non-Boolean result,
so it turns out you are right, "=" token is available.

-- 
Alexander S. Klenin




More information about the Lazarus mailing list