I saw this, but I thought the actual FPC document is the true reference, and I could not find that statement in there.
The FPC documentation being the true reference does not necessarily mean that it is complete and/or bug free. Please file a bug against the documentation.
So there is no way to declare an operator for a simple type like integer in Delphi mode? Just for records and classes and in their context?
Nearly correct: only records support operators (in either mode).
Also as a solution you can put your type and the operator overloads into a separate unit compiled in mode
ObjFPC and use it in a unit with mode
Delphi. Cause the operator resolution does not depend no the mode (the only exception is the
+-operator for dynamic arrays which depends on the modeswitch
ArrayOperators).
I like to use objfpc but it has its own problems like needing specializing every generic method for every use: https://forum.lazarus.freepascal.org/index.php/topic,52007
Correction: you need to write the
specialize keyword every time. But the specialization itself is handled the same in both modes.
@Bart, yes and I updated the question.
BTW, I checked with trunk so it is not fixed.
The only fix necessary is a fix for the documentation. That global operators are not allowed in mode Delphi is by design and choice. Please file a bug report for the documentation, so that this is cleared up.