Hi Thomas,

Some quick answers in addition to Nigel's

> 1) tail recursion

We use the usual "trampoline" trick, with a little top-level interpretative
loop. Using the trick has a pleasant side effect that we can pass values on
the arguments stack as well.

> 2) polymorphism

All type informations gets erased, ie polymorphism in the source language
becomes "Object" in Java.

> 3) closures & eval (i.e., laziness)

Below is the example code generated for S f g x = f x (g x). Thunk objects
intercept evaluation and update their code field. You recognize the
trampoline-trick as we return f instead of ENTER-ing it.

public class S implements Code {
    public Object ENTER () {
        VM.COLLECT(3, this);
        final Object f = VM.POP();
        final Object g = VM.POP();
        final Object a = VM.POP();
        VM.PUSH(new Thunk(new Code(){
            public Object ENTER () {
                VM.PUSH(a);
                return g;
            }
        }));
        VM.PUSH(a);
        return f;
     }
}

You will find a little more detail on
<http://www.cs.uu.nl/~erik/MondrianDescription.html> and on the Mondrian
homepage <http://www.mondrian-script.org/>.

We are trying to come with a new release real soon,

Erik


Reply via email to