Skip to content
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

Design by contract #11

Open
Victorious3 opened this issue Sep 24, 2022 · 0 comments
Open

Design by contract #11

Victorious3 opened this issue Sep 24, 2022 · 0 comments
Labels
proposal New feature or request

Comments

@Victorious3
Copy link
Contributor

It would be nice to leverage existing syntax here:

def my_function(a: int, b: int) -> int {
    assert a > 10
    assert b > 20
    return a + b
    assert return > 30
}

Every assert at the start of a function would build a pre condition, and asserts after return build post conditions.

The alternative would be using pragmas like this:

def my_function(a: int, b: int) -> int {
    #pre a > 10
    #pre b > 20
    #post return > 30
    return a + b
}

Upside would be not needing to define post conditions for every return statement but it would also make it less flexible in that regard.

@Victorious3 Victorious3 added the proposal New feature or request label Sep 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant