funny characters in identifiers?
Per Bothner
per at bothner.com
Tue Dec 28 10:21:57 PST 2010
Is there a plan/consensus for how to handle "illegal" characters
in identifiers? I'm primarily interested in the bytecode level,
not the Java source level. For example identifiers like '/'
used for division in Scheme. It would be good to have a standard
way to deal with this.
One solution is to use a reversible mangling transformation.
That's not necessarily ideal - for example it might be better to
translate a Scheme hyphenated name 'open-input-file' to Java style
'openInputFile' for interoperability with Java, but Scheme code
still needs a way to get the original name.
(Kawa current solves this by translating open-input-file to
an openInputFile method plus a static final Procedure-valued
field 'open$Mninput$Mnfile'.)
A general solution would seem to be to use an annotation. That
is what we did for JavaFX. Specifically:
/**
* Annotation to indicate the JavaFX source name a member derives from.
* Used when a the name was "mangled" to field a member name.
*/
@Retention(RUNTIME)
@Documented
@Target({METHOD, FIELD, TYPE})
public @interface SourceName {
String value();
}
It would be nice to standardize on an annotation type.
It would also be nice to generalize to support XML (and CommonLisp)
two-part names.
Perhaps:
public @interface SourceName {
String value();
String prefix() default "";
String namespaceURI() default "";
}
--
--Per Bothner
per at bothner.com http://per.bothner.com/
More information about the mlvm-dev
mailing list