java-oo icon indicating copy to clipboard operation
java-oo copied to clipboard

custom operators

Open pablogrisafi1975 opened this issue 11 years ago • 1 comments

You are a genius! Thanks for your wonderful job! What about defining custom operators? maybe not as flexible as Scala, when you can have the pope operator <+|:-) if you want. But I was thinking about the eq operator, so a eq b means Object.equals(a, b). It allows you to skip null checks, keep the == for references, and it is nicer on the eye.

Also, one small thing, the example code is somehow wrong, map.get("qwe")==null is not the same as map.containsKey("qwe") unless map is null free.

(I was also going to ask about null handling with ?, but pretty much everything I want to ask is already written in 'ideas' file)

Again, incredible work!

pablogrisafi1975 avatar Sep 28 '14 18:09 pablogrisafi1975

from #22: Adding new operators is very complicated. To do it we need to extend Java parser but oo-plugin only works after parsing (in annotation processing stage). There are no extension points before annotation processing in Java7 compiler. But there is some support of plugins in Java8 compiler (-Xplugin). Maybe it is possible to extend parser there. More research needed.

About map["qwe"]. Yes. It is not the same. I just tried to fit more use cases in small example. The difference doesn't really matter for the example. Thanks

amelentev avatar Oct 20 '14 22:10 amelentev