Initialization Data Methods

It is often convenient if data methods can assume that all variables of a data class have been initialized. This can be achieved by calling an initialization data method directly after creating a new instance of the data class. To enforce that such an initialization method is called, the initialization data methods should be annotated with "@Init".

A data class can have multiple initialization methods, but only one of these methods has to be called. If a data class has no methods with this annotation, no initialization method has to be called. The "@Init" annotation is not inherited by subclasses.

Example

data class Addition
variables
	requiredInt : Integer
methods
	@Init
	initAtZero() : Integer
		requiredInt := 0;
		return requiredInt
			
	@Init
	initAt(i : Integer) : Integer
		requiredInt := i;
		return requiredInt
		
	add(i : Integer) : Integer
		requiredInt := requiredInt + i;
		return requiredInt


process class SomeClass()
ports
messages
variables
init
	someMethod()()
methods
	someMethod()() | a : Addition |
		a := new(Addition) initAtZero()