Skip to content

Commit 721d588

Browse files
authored
Introduce design by contract concepts in RAP15.md
Added ideas for design by contract in RAP15.
1 parent 9110052 commit 721d588

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

  • courses/RascalAmendmentProposals/RAP15

courses/RascalAmendmentProposals/RAP15/RAP15.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,5 +153,15 @@ This simplifies the implementation of the type-checker and the interpreter alike
153153
* Think of another syntax for non-linear matching and forget about all the other possible conditions.
154154
* 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).
155155

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).
164+
165+
156166
## References
157167

0 commit comments

Comments
 (0)