[fpc-devel] Generic class comparison operators

Sven Barth pascaldragon at googlemail.com
Sun Apr 18 09:37:29 CEST 2021


Ryan Joseph via fpc-devel <fpc-devel at lists.freepascal.org> schrieb am So.,
18. Apr. 2021, 02:18:

> Since I'm working on generics right now can we finally, at the very least,
> allow class operators for comparison operators? This is literally the only
> way for a generic class to override the = operator (along with some others)
> so there's no reason not to allow this. I understand the objection to :=, +
> etc.. where it returns a copy of a class instance and people could in
> theory do memory unsafe things, with comparison operators there is no
> possibility for this. I already made a patch for "advanced records" which
> is in limbo but It's trivial to adapt this for classes and put restrictions
> on the type of operator.
>

It has been decided back when operator overloads were introduced that they
do not replace existing, built in operators. This decision still stands.
And we see no reason to change that. This way a user can *rely* on what a
certain operator means based on the language reference guide. This is more
important than some convenience for certain use cases.

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20210418/7b5ef3ec/attachment.htm>


More information about the fpc-devel mailing list