PRE-PROPOSAL: Simple operator overloading. (original) (raw)
rssh at gradsoft.com.ua rssh at gradsoft.com.ua
Wed Mar 25 05:28:03 PDT 2009
- Previous message: PRE-PROPOSAL: Simple operator overloading.
- Next message: PRE-PROPOSAL: Simple operator overloading.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
If you have some free time, I suggest you (or anybody in community) to initiate such proposal for one pair of operators (for example [] and []=). (Why only for one pair - because it would be small; build logical structure for all operators during 5 days is impossible. ).
And well-narrowed proposal for array access, may be have some chance.
Rules for array access (15.3) and assignment expression (15.26.1) can be copied from 'Simple Operator Overloading' near verbatim, just change existence of operator to existence of interface.
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! Vil.
2009/3/25 <rssh at gradsoft.com.ua>: Permanent URL: http://docs.google.com/Doc?id=dhhvggr818djp85shk
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.
- Previous message: PRE-PROPOSAL: Simple operator overloading.
- Next message: PRE-PROPOSAL: Simple operator overloading.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]