Class definitions
Class definitions in PIL have the following syntax:
class namespace::ClassName [extends SuperClass] {
class-body-declaration*
}
Note that whereas in Java a namespace (or package name) is defined for entire file, this is not the case in PIL. Each class declaration also declares the namespace it is defined in pas part of the class name. If no superclass is supplied it will default to pil::Object.
There are four types of class body declarations:
- A constructor definition
- Field definitions
- Method definitions
- Type conversion methods
Constructor
A constructor method has the following syntax:
new(ArgType arg1, ArgType arg2, ...) {
...
}
Note that unlike Java and C#, the constructor always has the name new. The constructor is invoked when a class is instantiated using new ClassName(...).
Fields
Fields in PIL always have to be initialized, as follows:
Type fieldName = initialValue;
for instance:
Int count = 0;
