forked from parapluu/encore
-
Notifications
You must be signed in to change notification settings - Fork 0
Default field values and default parameters #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
knikamo
wants to merge
18
commits into
development
Choose a base branch
from
defFieldValues_defParams
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit allows using any type where an `unsafe` parameter is expected, making `unsafe` the escape hatch for parametric constructs. It is needed for the implementation of `bestow`.
…rapluu#789) * Disallow silently capturing an active this as a passive reference Before this commit, in an `active` class, you could use `this` to access fields or (synchronously) call methods inside a closure. Because the mode of `this` is `active`, which is safe, the mode of the closure would allow it to be shared, leading to potential data-races. This commit changes an `active` `this` to a `local` variable if it is used for synchronous accesses. This forces the `local` mode on a closure containing e.g. `this.foo()`. There are also some improved error messages and a small check for when a required `var` field is provided as a `val` field. Fixes parapluu#781. * Dumb down C-type name generation For C readability reasons, when a mode was available for a class, the C name would include the name (e.g. `_enc__read_String_String_t`). This breaks having multiple views of `this` in an active class, so this commit removes it (writing `class` instead of the mode).
* Add range information to parsed nodes This commit extends the source position to include the range of positions of an Encore AST-node. Before, when parsing an expression, e.g. `(2,3)`, we would only know where the expression began. Now we also have information on where the expression ends (in this example 5 characters after the beginning). This is not visible to the programmer in any way, but is integral for the upcoming editor mode support. * Refactoring
Reacted to @kikofernandez' comments from parapluu#790. All in all, 56 lines shorter!
* Added forward for future chain case * Grouped common functions * Added error message * Added forward on preexisting future * Clean up code * Fixed and Added one testcase for preexisting future * Temp commit, could be removed * Generate id function * Rebase and keep forward(arg) code comments * Add minor fix * Add minor fix * Added forward on preexisting future * Fixed forward(id(arg)) and removed commented codes * Fixed general cases in Optimiser * Clean up code * Renamed function, removed bad codes, and added more testcases * Revised new test, removed unsed error message * Removed unused function * Refactored code * Changed to static future_chain, renamed function
This commit gets rid of a C-warning when the body of a loop does not have the type `unit`. No test has been added, as warning output cannot be tested. Fixes parapluu#759.
This commit adds to the error message the position of a match expression when no case matches. A test has been added. Fixes parapluu#733.
* Adding Pedestrian simulation stress test. For configuration options, see src/tests/stress/pedsim/README.md * Removed some unused methods, comments, general cleanup * more cleanup * used private method keyword to make a method private * removed binary file * removed big problem instances * removed big problem instances * Fixed dumb of by one in setup * undid unintential change to Makefile * Lifted number of time steps to become a parameter for the simulation * Lots of small changes * Changed an error message to make dave less sad * removed binary file
* cast print * fix printing intptr_t * fix to decimal format
028de29 to
2cc5f80
Compare
aeee00e to
803118b
Compare
This commit has squashed the following commits into a single one - removing pbcopy - prepare for default values - exprimenterar med seq väldigt nära nu - default field parameters working with bugs - do not desugar field without expression - refactor. adding comments - deacent looking - adding basic test for default params - moving to other class - More tests - testing expressions and adding out - moving - adding test for defaultParameters - removing binary - adding test for finalizer - adding tests for multiple constructors
- myser lite - funkar lite gran sådär - chaning test - working for functions - testar lite - got first part, (method decl) of default paramaters for methods working. ie this.test1()
This commit has squashed the following commits: - default params for methods fixed - default params for function does not work - default params for functions working - added tests for default params - string as default param in function fixed - removed finalize- and multipleInits-tests - default paramters for local functions fixed - removed a comment - added a test for object as default parameter - edited test for object as default parameter - added test for default field values in a class without an init method - removed comment - git fix - default field values works for class without init - removed files - small fixes
This commit adds an implicit call to `init` at the beginning of the `main` method. It also adds a restriction from defining a constructor method in the `Main` class. "Why this madness?" I hear you ask. This is to give field initialization a place to be desugared into, while still keeping `main` as the starting point of the program.
803118b to
7268677
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Default field values
Default field values are assignments added at the top of the init-method during desugaring. Default field values does not work for the main class since the init method is not called. Tobias suggested that he would solve this. There is currently no logic to prevent circular references or other unwanted expressions.
Default parameters
For each default parameter in a function/method declaration a new function/method is added during desugaring. During typechecking all function/method calls are adjusted to call the function/method with correct number of arguments. Default parameters work as expected according to the tests we have added.
General
We have not done anything with error handling or error messages. For example the error message for wrong number of arguments is now a bit weird since a function/method not always expects a fixed number of arguments.
We have written a few tests for each feature, but probably they do not cover everything.