Skip to content

Add new do/anonymous function block syntax #528

@mtshiba

Description

@mtshiba

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 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCNew specifications of ErgenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions