funny characters in identifiers?

Charles Oliver Nutter headius at headius.com
Tue Dec 28 13:58:22 PST 2010


On Tue, Dec 28, 2010 at 12:21 PM, Per Bothner <per at bothner.com> wrote:
> 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.

See John Rose's post on this here:
http://blogs.sun.com/jrose/entry/symbolic_freedom_in_the_vm

We have implemented it in JRuby, and it works well. The down side is
that Java backtraces can be a little hard to read when there's lots of
symbolic identifiers.

> A general solution would seem to be to use an annotation.  That
> is what we did for JavaFX.  Specifically:

In JRuby, we have a JRubyMethod annotation we can attach to either
hand-written or generated bytecode methods which has a "name" field.
We generally use it only for binding methods written in Java to a Ruby
name:

    @JRubyMethod(name = {"[]", "slice"}, reads = BACKREF, writes =
BACKREF, compat = RUBY1_8)
    public IRubyObject op_aref(ThreadContext context, IRubyObject
arg1, IRubyObject arg2) {
        Ruby runtime = context.getRuntime();
        if (arg1 instanceof RubyRegexp) return subpat(runtime,
context, (RubyRegexp)arg1, RubyNumeric.num2int(arg2));
        return substr(runtime, RubyNumeric.num2int(arg1),
RubyNumeric.num2int(arg2));
    }

- Charlie

- Charlie


More information about the mlvm-dev mailing list