Because of initialization constraints*, all variable declaration are translated to non-initialized private fields. This means that no variable can be immutable.
*: Imagine declaring a variable and then use it in the initialization of another variable. Example:
param String hello
val String value = hello + "world"
hello is initialized later (in the constructor), but value is immutable. Now, look at this:
param String hello = "initial value"
val String value = hello + "world"
hello has a default value, but it can be replaced during the subsystem initialization. what value should be used for value? (answer: if the blank constructor is used, then the default value). This means that the initialization of both variables need to be done in a second step.
Because of initialization constraints*, all variable declaration are translated to non-initialized private fields. This means that no variable can be immutable.
*: Imagine declaring a variable and then use it in the initialization of another variable. Example:
hello
is initialized later (in the constructor), butvalue
is immutable. Now, look at this:hello
has a default value, but it can be replaced during the subsystem initialization. what value should be used forvalue
? (answer: if the blank constructor is used, then the default value). This means that the initialization of both variables need to be done in a second step.Summary: remove "val" from the grammar.