Have constructor list for more human like C++ code as well as more flexible immutable variables (Ignore the failed testcases, trust me bro) #50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This will most likely fail a good portion of unit tests due to the change in how constructors are compiled now. I added constructor list support for the compiler because I came across a situation with my own learning project that would almost require the argument to be put in the constructor list since the class's property variable was immutable. Let me show an example. I do recommend doing some further tests of your own to see if there might be any issues.
This is the Test.hx I used:
And here is how it would look before this PR:
And I received an error since I'm trying to overload an immutable variable. However, I really just want to initialize my variable with my argument.
Now with this PR, I can do exactly that without removing the
@:const
keyword:There we go! It works!