cincheo / jsweet

A Java to JavaScript transpiler.
http://www.jsweet.org
Other
1.46k stars 160 forks source link

annotation mapped method overloading #51

Closed metrospiegel closed 8 years ago

metrospiegel commented 8 years ago

It would be great for existing implementations/libraries (even though this is not the main purpose of JSweet) which cannot be structurally changed, to have the option of mapping diffrent method overloadings to diffrent method names. I know, it is not so easily implemented. Especially if it is done with some covenience considered. But would greatly benefit migrators.

renaudpawlak commented 8 years ago

Could you give an example? That would help me to make sure that I fully understand what you are saying. Is it related to issue #27 ? I would say it is very close.

metrospiegel commented 8 years ago

It concerns a same problem of me as #27 (EMF migration). Here my example:

@jsRename({"insertBooleanAt"}) void insertAt(int pos, Boolean val) { ... } @jsRename({"insertStringAt"}) void insertAt(int pos, String val) { ... }

However, i just also discovered the instanceof limitation, which does not belong here but poses also a problem for what i want to do. So maybe the scope of JSweet is really diffrent than i thought and hoped. Which would make also my other posts obsolete.

renaudpawlak commented 8 years ago

Closed as redundant with issue #27

lgrignon commented 8 years ago

This discussion could join a bigger discussion which is the @Name annotation support. Even if the EMF migration case is not the primary JSweet case, the @Name support for user methods is pretty interesting. Indeed, it could provide a powerful workaround for many situations, not only overloads but for instance some unsupported reserved java keywords (in the future).

It seems to me that it would not be complicated to implement but could solve some blocking situations.

What do you think about it?