> On Apr 17, 2021, at 2:12 PM, Jonas Maebe via fpc-devel > <fpc-devel@lists.freepascal.org> wrote: > > The issue with allowing it for classes (generic or not) is that the the = > operator already has a meaning for them (pointer equality). I think in > general we don't allow overloading operators that have a built-in meaning.
I see your point about there being a conflict for pointer quality but you can actually resolve it by casting to TObject, however as you note it could be confusing also. That's an interesting question I'd need to think about more but even so that is only the = operator with other pointer types. Here's the list of possible operators that don't have side effects to the caller and are worth considering and may be safe. class operator = (left: TSelf; right: TRight): boolean; class operator not (left: TSelf): boolean; class operator <> (left: TSelf; right: TRight): boolean; class operator < (left: TSelf; right: TRight): boolean; class operator > (left: TSelf; right: TRight): boolean; class operator <= (left: TSelf; right: TRight): boolean; class operator >= (left: TSelf; right: TRight): boolean; class operator >< (left: TSelf; right: TRight): boolean; class operator in (left: TSelf; right: TRight): boolean; Regards, Ryan Joseph _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel