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

Add new do/anonymous function block syntax #528

Open
mtshiba opened this issue Sep 30, 2024 · 0 comments
Open

Add new do/anonymous function block syntax #528

mtshiba opened this issue Sep 30, 2024 · 0 comments
Labels
enhancement New feature or request RFC New specifications of Erg
Milestone

Comments

@mtshiba
Copy link
Member

mtshiba commented Sep 30, 2024

We propose new syntax for do/anonymous function block,

do { ... }
i -> { ... }

which is equivalent to

do:
    ...
i ->
   ...

This syntax makes it easy to pass blocks to a function.

foo do { ... }, i -> { ... }, j -> {
    ...
}, k -> {
... # no indentation allowed
}

The { immediately after do, ->(=>) is not considered to be the { of a brace container (set, record, dict).

i -> { i + 1 } # : Nat -> Nat
i -> { {i + 1} } # : Nat -> Set Nat
k = 3
do { i = 1; j = 2; k } # : () -> Nat
do { { i = 1; j = 2; k } } # : () -> { i = Nat; j = Nat; k = Nat }
@mtshiba mtshiba added enhancement New feature or request RFC New specifications of Erg labels Sep 30, 2024
@mtshiba mtshiba added this to the v0.7.0 milestone Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request RFC New specifications of Erg
Projects
None yet
Development

No branches or pull requests

1 participant