You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: courses/RascalAmendmentProposals/RAP15/RAP15.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -153,5 +153,15 @@ This simplifies the implementation of the type-checker and the interpreter alike
153
153
* Think of another syntax for non-linear matching and forget about all the other possible conditions.
154
154
* Introduce a type system with dependent types (the current solution comes really close to a *dynamic* dependently typed system; a static dependently types system is much more involved and also hard to work with for programmers since nothing runs until it type-checks).
155
155
156
+
## Design by contract (ideas for a next RAP)
157
+
158
+
* An observation: `if` clauses to patterns offer a way to express strongly enforced _preconditions_ on the input parameters (contracts).
159
+
* And, there is [RAP](https://www.rascal-mpl.org/docs/RascalAmendmentProposals/RAP7/) for enforcing immutability of all pattern variables. Assume we accept this.
160
+
* with immutability of the input there is no need for a notation to looking back in time when formulating post-conditions.
161
+
* And, we also assume global variables will not be mutable in the future anymore (only local variables). Otherwise we need a notation for preconditions on globals next to the `if` on patterns.
162
+
* Then the question remains: What would be a syntax for imposing post-conditions on the return value, which would mirror the conditions on input variables nicely?
163
+
* For example `"return" Expresion expression "if" Expression condition ";";` would go a long way, where the function throws `CallFailed()` for example if it can not satisfy the post condition(s).
0 commit comments