PRE-PROPOSAL: Simple operator overloading.

Vilya Harvey vilya.harvey at
Wed Mar 25 05:03:37 PDT 2009

I would love to see this, but I'd prefer it to be based on special
interfaces rather than annotations. This would adhere to the
principle, mentioned on this list a few times, that annotations
shouldn't modify the results of the compiler.

For example, if you implement the Addable (say) interface then your
class can be used the '+' operator; or the Subtractable interface for
the '-' operator. I'd imagine you would also want some grouping
interfaces, to reduce the number of interface declarations required
when overloading multiple operators (e.g. interface Artihmetic extends
Addable, Subtractable etc.).

Whatever form it takes though, it would be great to have this
capability in Java!


2009/3/25  <rssh at>:
> Permanent URL:
> Probably too big, but anyway.
> As I remember, alternative proposal (made [] and []= syntax sugar on
> well-known interfaces, as with for-each loop) still not submitted. If
> anybody want submit such proposal, then it is possible to reuse
> JLS-changed for 15.26.1 from there.

More information about the coin-dev mailing list