[fpc-devel] Operator overloading and {$mode delphi}

Ben Grasset operator97 at gmail.com
Sun Apr 14 03:58:06 CEST 2019

On Sat, Apr 13, 2019 at 6:04 PM Sven Barth via fpc-devel <
fpc-devel at lists.freepascal.org> wrote:

> Maybe we should mention that in the documentation...

AFAIK it's never been possible to use FPC-style operator overloading in
mode Delphi... is it supposed to be allowed?

For example:

unit Unit1;

{$mode delphi}


  Classes, SysUtils;

  TRec = record

operator Implicit(constref ARec: TRec): String;


operator Implicit(constref ARec: TRec): String;


That program gives: "unit1.pas(14,10) Fatal: Syntax error, "=" expected but
"identifier IMPLICIT" found"

Why it is specifically expecting "=", I have no idea. In general though I
don't recall ever having successfully used non-"class operator" operators
in {$mode Delphi}.

WRT the docs, there's a lot of things they don't mention. They entirely
ignored the fact that records and objects (not just classes) can be
enumerators until a few days ago.

Of course, nobody's gonna know the docs have been updated for a long long
time, because they only get built every couple of years or so at best...
(Unless you do it yourself, which is not even *that* hard, but still way
harder than it *should* be in a manner that is rather far removed from
FPC's usual cross-platform nature for pretty dubious results: i.e. the docs
are pretty much *just ok*, not super great or anything.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20190413/aee39982/attachment.html>

More information about the fpc-devel mailing list