[fpc-devel] class operator overloads
Sven Barth
pascaldragon at googlemail.com
Tue Apr 16 22:51:58 CEST 2019
Am 16.04.2019 um 18:21 schrieb Ryan Joseph:
> Nagging question I had that I would like answered. I was told that we can’t have operator overloads on classes (only records) because there is a potential temporary class that could be created and thus some kind of automatic memory management would be needed. How is this any different than function operator overloads? If you allocated a new class in "operator +” then you would get a memory leak right? If that’s true then I don’t understand why we can’t have them in the actual class structure.
It's the same problem there.
The thing however is that FPC's operator overloading support is quite
old (compared to Delphi's) and it's possible that it is even older than
the support for Delphi's class type. So the global operators simply
gained support for classes by "accident" while the ones nested in
records came much later by choice. Adding support for operators inside
classes would be a choice as well.
Regards,
Sven
More information about the fpc-devel
mailing list