Type name resolution
In Meso, there is no data type named int or double. Every data type's name is a full UTL, such as meso:int or java:double. The UTL can be resolved from a type identifier against namespace and import statements similar to that in Java. The scheme of the namespace is also used to resolve the identifier.
For example, in the following program:
namespace meso:foo;
import imop:example.com/abc.*;
import java:java.foo.*;
class Service {
Bar b; // what UTL is this type identifier "Bar"?
}
When resolving the type identifier Bar, the Meso compiler will try to locate these data types:
meso:Bar meso:foo.Bar imop:example.com/abc.Bar java:java.foo.Bar
If more than one is found, an ambiguous error will be thrown. One may use an explicit import statement, which has precedence over wildcard imports, to solve the problem:
namespace meso:foo;
import imop:example.com/abc.Bar; // explicit import
import java:java.foo.*;
class Service {
Bar b;
}
If more multiple Bar types is needed in code, just put its full UTL in code directly:
namespace meso:foo;
class Service {
imop:example.com/abc.Bar b1;
java:java.foo.Bar b2;
}
Full UTL can be used in replace of a simple type identifier everywhere. For example, the following two programs are equivalent:
namespace meso:foo;
class Service implements java:java.lang.Runnable {
public void run() {
java:java.lang.System.out.println( "Howdy!" );
}
}
namespace meso:foo;
import java:java.lang.*;
class Service implements Runnable {
public void run() {
System.out.println( "Howdy!" );
}
}
Notice that the scheme of the namespace also participates the type resolution process. For example, in the following program, int is resolved as meso:int:
namespace meso:foo;
class Service {
int x; // meso:int
}
