[patch] 6746458 support for exotic identifiers (identifier superquote)

Rémi Forax forax at univ-mlv.fr
Wed Sep 10 16:28:12 PDT 2008


Per Bothner a écrit :
> Jonathan Gibbons wrote:
>> Since the characters are illegal at the JVM level, what's the reason 
>> for allowing them?
>
> See the first paragraph of John's announcement: to allow integration
> with other langauges, that don't have those restrictions (or have
> different restrictions).
>
> For example, the Lisp/Scheme divide function is named "/" - a simple
> implementation strategy is to use static Java methods with the same
> name:
>
> public class LispBuiltins {
>   ...
>   public static Object #"/" (Object x, Object y) { ... }
> };

or an annotation :
public class LispBuiltins {
  ...
  @Operator("/");
  public static Object slash(Object x, Object y) { ... }
}

Annotation work well when declaring a  method,
but doesn't help at call site i.e. when you want to call
non-Java method.

Anyway, i'm not sure it's a good idea to change the Java spec
in order to be able to call a method with a non Java name.
Why don't just use a bridge method ?

Lot of languages perform some convertions of arguments
before calling their methods, in my opinion,
exotic identifiers support is just a part of that adaptation process.

Calling a non-Java method from Java without adaptation seems
to be a great idea but not very practical.

cheers,
Rémi





More information about the compiler-dev mailing list