Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

Immutable values should be removed from the language #28

Closed
jachinte opened this issue Jul 7, 2016 · 0 comments
Closed

Immutable values should be removed from the language #28

jachinte opened this issue Jul 7, 2016 · 0 comments

Comments

@jachinte
Copy link
Collaborator

jachinte commented Jul 7, 2016

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant