Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing arithmetic method names for operator overloading support #3

Open
elect86 opened this issue Sep 26, 2016 · 0 comments
Open

Comments

@elect86
Copy link
Collaborator

elect86 commented Sep 26, 2016

There is a nice project here that allows to have operator overloading support.

It is basic but still a huge step for java devs.

There are some drawbacks though at the moment:

    Map<String, String> binary = new HashMap<String, String>() {{
        put("+",    "add");
        put("-",    "subtract");
        put("*",    "multiply");
        put("/",    "divide");
        put("%",    "remainder");
        put("&",    "and");
        put("|",    "or");
        put("^",    "xor");
        put("<<",   "shiftLeft");
        put(">>",   "shiftRight");
        put("<",    compareTo);
        put(">",    compareTo);
        put("<=",   compareTo);
        put(">=",   compareTo);
    }};
    String revSuffix = "Rev";
    Map<String, String> unary = new java.util.HashMap<String, String>() {{
        put("-", "negate");     // jdk7
        put("---", "negate");   // jdk8
        put("~", "not");
    }};
    String   compareTo = "compareTo";
    String   indexGet = "get";
    String[] indexSet = new String[]{"set", "put"};
    String[] valueOf = new String[]{"valueOf", "of"};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant