Am 02.07.2012 04:46, schrieb JC Chu:
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.)

The best source of information is the compiler source itself. The whole logic that decides whether an operator is overloadable or not is located in htypechk.pas, isoperatoracceptable and more imporantly also isbinaryoperatoroverloadable. From what I see everything is forbidden except what is written in there as an exception (and the ** operator which is always allowed).

Maybe I should start preparing for a bug report?

Maybe there were reasons to not allow them... You can of course prepare a bug report or wait till one of the other developers who are more experienced in FPC's overloading speak up.

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to