LazyJ: Seamless Lazy Evaluation in Java

Alessandro Warth

LazyJ is a backward-compatible extension of the Java programming language that allows programmers to seamlessly tap into the power and expressiveness of lazy evaluation. It does so by extending Java's type system with lazy types. A variable of type lazy T (where T is any Java type) can hold a thunk which when evaluated will yield a value of type T. The existence of coercions between non-lazy and lazy types eliminates the need for explicit delay and force operations.

In this paper, we introduce LazyJ with several motivating examples and formalize the semantics of the language with Featherweight LazyJ, an extension of Featherweight Java. We also describe our implementation, which is built on top of the Polyglot extensible compiler framework.

[Full paper (pdf)]

o

Presented at FOOL/WOOD; Saturday, 20 January 2007; Nice, France