Skip to content

custom operators #24

Open
Open

Description

@pablogrisafi1975

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!

Activity

  1. amelentev commented on Oct 20, 2014

    @amelentev
    Owner

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions