Language idea: Function contracts #32
Labels
area: language
Issues related to the design of the language.
state: deliberation
Issues that require design work and/or discussion.
Milestone
It would be interesting to see if there's something we can do in this space. We have the
assert
statement currently, but I think there's room for a more principled feature here.The feature would need to support preconditions and postconditions (with access to the return value). Preconditions would run before any code in the function, while postconditions would need to run after any
defer
anduse
statements in the function. Postconditions would only run when an error is not raised from the function.Compile-time contract checking would be out of scope initially, but could always be done on a best-effort basis later down the line.
I have no idea what the syntax would look like yet.
The text was updated successfully, but these errors were encountered: