[fpc-pascal] Custom operators for non-record types

JC Chu jcchu at acm.org
Mon Jul 2 04:46:55 CEST 2012

Do you have some inside information on the extra limitations regarding
ordinal, floating point, and set types?

As I understand, the only limitation on operator “overloading” should
be that the operator do not have a default interpretation for the
operands–result type combination.

The modulus operator, for example, is certainly not defined by default
as (Double, Double) → Double; but when I try to define it, the
compiler says it’s an “[i]mpossible operator overload”.  The same goes
for logical operators on enumeration types.  (Although each
enumeration element has an underlying numerical value, it requires the
use of Ord() or an explicit cast to convert it into a numerical type
accepted by bitwise logical operators.)

Maybe I should start preparing for a bug report?

On Mon, Jul 2, 2012 at 3:41 AM, Sven Barth <pascaldragon at googlemail.com> wrote:
> Some parameter combinations are not allowed, because certain inline
> operators are already in place. I don't know their exact rulings, but
> ordinals (Integer values, floating point values), enums and sets are a bit
> restricted regarding overload (especially if it is a binary operator where
> left and right is of such a type).

Best regards,
JC Chu

More information about the fpc-pascal mailing list