Java$\Omega$: Preprocessing Closures in Java

The paper adds a mechanism of {\em closure} to Java. We apply to closures the same technique we exploited in extending Java with methods as parameters \cite{bellia2008,bellia2008c} and we obtain a formal definition and a prototype of Java with closures. The formal definition consists of a set of source to source translation rules that state the meaning of the new construct in terms of compositions of well known ordinary Java structures. Two variants of the transformation are discussed to allow recursive defined closures and other mechanisms. The notion of {\em shared variable} as a local variable that is allocated in the heap is also discussed. Eventually, since the resulting transformation is one pass process, it can be implemented through a source to source, one pass, preprocessor \cite{bellia2007,bellia2008b}, easy to write using standard development tools \cite{levine1995,donnely2006}.