On Jan 17, 2008 1:06 PM, Charles Oliver Nutter <[EMAIL PROTECTED]> wrote:

> * Then we used a hand-written indexed method handle like you describe.
> Again, it worked (albeit a bit slower than individual methods), but it
> was too much effort to implement by hand and wouldn't work for generated
> code.

I don't understand the force of this objection.  In source code, I
have something like this:

public class Foo extends Function {
  public Foo(int n) { _index = n; }

  private static int BAR = 1;
  private static int BAZ = 2;
  private static int QUUX = 3;

  public static Foo BarFunction = new Foo(BAR);
  public static Foo BazFunction = new Foo(BAZ);
  public static Foo QuuxFunction = new Foo(QUUX);

  public Object _invoke(Object... args) {
    switch(_index) {
    case BAR: return bar(args[0], args[1]);
    case BAZ: return baz(args[0]);
    case QUUX: return quux();
    default: throw new SomeError(...);
    }

  public static Object bar(Object a, Object b) { ... }
  public static Object baz(Object a) { ... }
  public static Object quux() { ... }
  }

That pattern is very amenable to both hand-coding and code generation,
and the only limit to it is how much code a class can hold.  The
private static constants are just for documentation in hand-written
code, and aren't used in generated code.  There is obviously a speed
problem resulting from the call-switch-call, but the great majority of
all calls bypass this path completely to invoke the static method
directly (namely, those which are direct in the source language).

> * One .rb script is compiled into exactly one .class file.

So Ruby classes don't correspond to JVM classes?

I create one Java class for every source-code class, plus (currently)
one for each embedded anonymous procedure, plus several more, one for
each distinct namespace in the source language (functions, lexical
variables, dynamic variables).

-- 
GMail doesn't have rotating .sigs, but you can see mine at
http://www.ccil.org/~cowan/signatures

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to