jamiebuilds / ghost-lang

:ghost: A friendly little language for you and me.
302 stars 10 forks source link

Function syntax #23

Closed aleclarson closed 5 years ago

aleclarson commented 5 years ago

Why was the explicit fn added? Why not..

# Function literals
let foo = (a, b): void {
  doSomething(a, b) # this return value is ignored because `: void`
}
let bar = async iter (a, b) {
  yield await doSomething(a, b)
}

# Function types
type Foo = (a, b): void
jamiebuilds commented 5 years ago

Because consistency:

let v = fn (...) {...}
let v = if (...) {...}
let v = for (...) {...}
let v = match (...) {...}
let v = while (...) {...}