Computer Science Department
Programming Methods Laboratory
(LAMP)
Compilation winter semester 1999/2000
Tutorial Slides 29.10.99
Programming Language Implementation
A Simple J0 Program
module M { // module
int i; // global variable
void foo() { // function
int k; // local variable
k = 0;
i = k;
}
int inc(int x) {
return x + i ;
}
int j;
}
Tutorial, 29.10.99
Programming Language Implementation
J0 Namespaces
A name is defined,
if the declaration is in the same or an enclosing block and
if the name is declared textually before accessing it
If there is more than one declaration in the enclosing blocks,
then only the innermost declaration can be accessed.
module M {
int i;
void init() {
int i;
i = foo(1);
}
int foo(int n) {
if (n == 0) {
return i;
}
return foo(n - 1);
}
}