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

Custom method names for overloaded operators #9

Open
Shockah opened this issue Jun 27, 2013 · 2 comments
Open

Custom method names for overloaded operators #9

Shockah opened this issue Jun 27, 2013 · 2 comments

Comments

@Shockah
Copy link

Shockah commented Jun 27, 2013

I never really made any Eclipse plugins and such, but could it be possible to use annotations to specify which method should be used as which overload? This way we could both name methods like they should be really named and still use Java-OO.

@BjarkeNL
Copy link

I really like this idea of allowing the use of annotations. This means that you don't have to add extra methods with other names to the public API of your classes, which are just aliases for the methods which the user is supposed to call when not using java-oo. Don't know if it is possible or how hard it is, though...

@amelentev
Copy link
Owner

It is possible to implement remapping method names for operators via annotations.
But it is not easy. It should be implemented in all 3 compilers (javac,eclipse,idea) separately because of different api.

How should annotations look like? For example:

@interface OperatorOverloading {
    String add() default "add";
}
@OperatorOverloading(add="plus")
class Test {
  Test plus(Test a) {...}
}

I see no major benefit from this.
Another issue is you can't annotate or modify external class for operator overloading. (For example in Kotlin language it is possible via extension functions)

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

No branches or pull requests

3 participants