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

Type annotations in Harmony #4

Open
anthonyyangdev opened this issue May 1, 2022 · 0 comments
Open

Type annotations in Harmony #4

anthonyyangdev opened this issue May 1, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@anthonyyangdev
Copy link
Collaborator

anthonyyangdev commented May 1, 2022

Type annotations in Harmony, similar to type annotations in Python, would greatly improve the experience of implementing and testing code. A proposal for type syntax is something like the following (using Diners.hny as an example):

from synch import Lock, acquire, release

const N = 5

forks = [Lock(),] * N

def diner(which: int):
    let left, right = (which, (which + 1) % N):
        while choose({ False, True }):
            acquire(?forks[left])
            acquire(?forks[right])
            # dine
            release(?forks[left])
            release(?forks[right])
            # think

for i in {0..N-1}:
    spawn diner(i)

Ideally, there would some type inferencing to avoid excessive type annotations, such as inferencing the type of i as int, left and right as int, or forks as a list of the return type of Lock. This change would require changes to the syntax of the language, but they likely would not significantly affect the overall structure of the existing parser.

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

No branches or pull requests

1 participant