Comments (2)
One possibility:
contract ::= contract-precondition contract-result-postcondition? contract-error-postcondition? |
contract-result-postcondition contract-error-postcondition? |
contract-error-postcondition
contract-precondition ::= 'in' block-expression
contract-result-postcondition ::= 'out' ('as' lower-identifier)? block-expression
contract-error-postcondition ::= 'err' ('as' lower-identifier)? block-expression
contract-statement ::= contract
statement ::= ... |
contract-statement
Semantics:
- Contracts are only allowed as the first statement in the top-level block of a function declaration (no lambdas).
- Contracts can access the function's parameter bindings.
- Contracts cannot access surrounding local bindings in the function.
- Contracts can mutate the result/error values (e.g. if they have mutable fields). This is unfortunate but would be very hard to prevent. A lint pass could catch obvious cases.
- Contracts cannot
ret
,raise
, or do error-propagating calls.
from celerity.
It would be better if we could incorporate contracts into function declaration and function type syntax in a similar way to what we did for result type and error type syntax...
from celerity.
Related Issues (20)
- Implement a Visual Studio extension HOT 2
- Implement a Visual Studio Code extension HOT 2
- Semantic analysis should reject `ret`, `next`, and `break` expressions in `defer` statements HOT 1
- Lint pass that warns on `try` expressions without `raise` expressions or error-propagating calls
- Handle various exceptions and error conditions in the driver gracefully
- Write a JSON schema for `celerity.json`
- Implement code formatting
- Remove pre-release flag from VS Code extension
- Configure all ESLint rules
- CI runs should upload build artifacts for debugging purposes
- `assert` should be an expression instead of a statement
- Make workspace APIs more flexible
- Project and workspace APIs should reject paths with `.` or `..` segments HOT 1
- Design and implement the AIR linear IR for the JIT compiler
- Introduce a concept of project solutions
- Redesign array patterns or consider array slicing HOT 1
- Add some example programs to the documentation HOT 2
- Language idea: Extended module type syntax and new module pattern syntax HOT 1
- Switch to Draco.Lsp for the language server HOT 1
- Implement semantic analysis for `tail ret` expressions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from celerity.