unicesi / amelia

:airplane: DSL for deploying distributed systems, with custom commands to compile and execute FraSCAti applications
GNU Lesser General Public License v3.0
2 stars 3 forks source link

Immutable values should be removed from the language #28

Closed jachinte closed 8 years ago

jachinte commented 8 years ago

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.

Summary: remove "val" from the grammar.