Thursday, April 15, 2010

New Mint Release: r15405

I just created a new release of Mint and DrJava with Mint: May 8, 2010 (r15405). The release is available from the Mint implementation page:

The DrJava team released a second beta version of DrJava yesterday, drjava-beta-20100507-r5246.

Nothing has changed on the Mint language side, but there have been minor changes in the Mint build process, and several examples have been added.

There have been plenty of new features and bugfixes for DrJava, and they have been integrated into DrJava with Mint. Most importantly, DrJava with Mint will now automatically select the Mint compiler on start-up.

5 comments:

  1. Dear Mathias,

    In the example Power.java (program at the end of the comment), the compiled function x -> x^17 is obtained by means of an anonymous extension of abstract class PowerFun, as shown subsequently:

    PowerFun spower17 = <| new PowerFun() {
    public int power(final int x){
    return `(power2(<|x|>, 17));
    }
    } |>.run();

    Now, imagine that I need to compile a new function that do:
    x,y -> x^17 + y^17
    How can I build the code for this function, and do it by reusing the already compiled function spower17.power(int) ?

    (I guess the anonymous class is final, but not PowerFun)

    Yours,

    Frédéric


    ---------------------------------------------------

    import edu.rice.cs.mint.runtime.Code;
    import edu.rice.cs.mint.runtime.SafeCode;

    public class Power{
    public static void main(String[] args){

    System.out.println(power(2, 17));
    long start = System.nanoTime();
    for(int x = 0; x < 20000; x++)
    power(2, 17);
    long unstaged = System.nanoTime() - start;

    PowerFun spower17 = <| new PowerFun() {
    public int power(final int x){
    return `(power2(<|x|>, 17));
    }
    } |>.run();

    System.out.println(spower17.power(2));
    start = System.nanoTime();
    for(int x = 0; x < 20000; x++)
    spower17.power(2);
    long staged = System.nanoTime() - start;

    System.out.println("Unstaged -> " + unstaged + " ms");
    System.out.println("Staged -> " + staged + " ms");
    }

    public static int power(int x, int n){
    if (n == 1)
    return x;
    else
    return x * power(x, n-1);
    }

    public static separable SafeCode power2(SafeCode x, int n){
    if (n == 1)
    return x;
    else
    return <| `x * `(power2(x, n-1)) |>;
    }

    public static abstract class PowerFun{
    public abstract int power(int x);
    }
    }

    ReplyDelete