That wiki entry is of really poor quality and is more or less not even a half-copy of the reference guide.
The
official reference guide is much better and quite comprehensive.
https://www.freepascal.org/docs-html/ref/refch15.htmlIt is not a new feature, btw, it exists for more than 10 (closer to 20?, fpc 2.x.x before 2.4.0 ) years.
The standard code base (rtl and packages) makes clever use of it in many places.
For example in the math unit, my overload for floating point mod such that you write modulo operations on floating point values more easily or the uComplex, matrix or real48unit or other mathematical stuff.
From the math unit:
operator mod(const a,b:float) c:float;inline;
operator ** (base,exponent : float) e: float; inline;
operator ** (base,exponent : int64) res: int64;
I use operators and write operators almost daily.
They are, as an example - the basis of my x-way logic systems. See for example:
https://forum.lazarus.freepascal.org/index.php/topic,41144.msg295325.html#msg295325 for examples
But I also use them in audio systems where I can add filters and effects by means of operator overloads to an audio stream.
It makes code often much easier to understand and - when inlined - do not have a speed penalty.
(E.g, my mod operator overload generates the same code as the fmod function that uses the same code and makes it simpler to translate the C style % fp mod operator)
I also use the much more recent management operators for records quite often, although these are conceptually may be quite a different beast.
People do not realize it, but you are probably using operator overloads daily.
Example from the objpas unit:
TMethod = record
Code : CodePointer;
Data : Pointer;
public
class operator =(const aLeft, aRight: TMethod): Boolean; inline;
class operator <>(const aLeft, aRight: TMethod): Boolean; inline;
class operator >(const aLeft, aRight: TMethod): Boolean; inline;
class operator >=(const aLeft, aRight: TMethod): Boolean; inline;
class operator <(const aLeft, aRight: TMethod): Boolean; inline;
class operator <=(const aLeft, aRight: TMethod): Boolean; inline;
end;
Btw, the wiki entry for
management operators is well written, for that special case:
https://wiki.freepascal.org/management_operators